Seeing some rather major deficiencies in how Advanced Installer surfaces errors from a sql script. Hopefully I'm missing something, but I've tried a lot of different options to get this to work.
Basically, if your script throws a run-time error, there is no real way to handle this in a way that a) provides fail-safe rollback and b) informs the user appropriately. Here is what I'm seeing:
Consider a basic sql server upgrade script that inserts a row into a table that has a primary key. If you turn on IDENTITY INSERT (common practice in some cases) and attempt to insert a row that already exists, you'll receive a primary key constraint error and your script will stop running. I understand you can check for existence, but that's a whole other topic.
This error IS NOT raised to the installer UI and the installer reports success.
Let's say the line before this did something else like add or drop a column in a table.
Advanced Installer options in this case are abort, run the next line or run the next script in the sequence.
if you abort, your database is left in an interim state where your column add/drop succeeded, but the rest of the script did not.
if you run the next line, you basically end in a different interim state where certain parts of the upgrade succeed or fail based on previous errors.
Neither state is acceptable.
Given that, I wrapped the entire thing in a try-catch, plus a transaction so I can roll it back myself and raise an error
This doesn't work either as far as I can tell from my testing.
if you abort, you are left in the same state as in the first case. Your try-catch never catches the exception and the transaction is not rolled back.
So i tried running the next line in hopes that I would fall into my catch block, rollback my transaction and raise an error that the user can see. No luck.
FOLLOW US
Get the latest news in Application Packaging