cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Wendy_Smith
Level 3

Conditional SQL Scripts during RollBack

Hi,

I have a basic MSI project which as part of the install creates an SQL database. The database create is done during the Execute phase. So, I have a corresponding Rollback script to drop (delete) the database. My issue is to only delete the database if it is in fact created during the install rather than an existing database.

During the UI sequence, I verify that the database does not exist, so I will know that if the database exists in rollback, it must have been created by the install. I then set the property ENABLE_ROLLBACKCREATEDB = 1 and add this as a condition on the RollBack SQL script.

However the condition does not seem to work. The database is always deleted even though for the case the database exists, I have verified that the property ENABLE_ROLLBACKCREATEDB = 0.

Any suggestions would be appreciated on how to implement conditional SQL scripts for Rollback execution.

thanks
Wendy Smith
Labels (1)
0 Kudos
(6) Replies
Wendy_Smith
Level 3

I have done some more testing and find that my SQL script conditions aren't being checked. I appear not to have the correct syntax or ?

For the test, I have created a property TESTENABLE with value 0 in the property manager. On the SQL script view, I specify the condition TESTENABLE=1. But the SQL script still executes.

Any ideas on what I'm doing wrong in setting the condition?

thanks
Wendy
0 Kudos
hidenori
Level 17

The conditions for rollback SQL scripts are ignored in InstallShield 2008. In order to get it workaround, I would suggest that you put a conditional statement in your SQL script as follows:

[LIST=1]
  • Add the conditional statement to your SQL script so that your database will be deleted conditionally. You need to use a placeholder that will be replaced with the value of your Windows Installer property at runtime. is the placeholder in the following example:
    if  = 1
    DROP DATABASE MyDBName

  • Add the Text Replacement entry below to your SQL script using the Script | Text Replacement tab in the SQL Scripts view:
    Find What:
    Replace With: [ENABLE_ROLLBACKCREATEDB]

  • Rebuild your setup.


    Hope that helps.
  • 0 Kudos
    Wendy_Smith
    Level 3

    Thanks,

    I tried the work around. It was straight forward to implement and this solves the conditions issue nicely.

    regards,
    Wendy
    0 Kudos
    npevler
    Level 3

    I am having a similar issue with 2009, the rollback is ignoring the script conditions and always attempting to rollback. My problem is compounded by the fact that the script which is attempting to rollback is on a db connection which does not exist. This is effectively what my condition checks. Is there any other way I can get the script conditions to action.
    0 Kudos
    hidenori
    Level 17

    One thing you can do is to set your condition on the ISSQLServerRollback action. Note that all of your rollback SQL scripts will not be executed when the condition evaluates to false.
    0 Kudos
    npevler
    Level 3

    Hi Hidenori,
    Thanks for the rapid response, unfortunately we have other SQL which does have to run. We are currently looking into using the IS_SQLSERVER_CXNS_ABSENT_FROM_INSTALL property to see if we can disable the connection we are not using before the rollback occurs. At the moment we have an immediate CA which disables the SQL connection if that part of the system is not being used then hopefully when the rollback occurs the rollback scripts for the unused connection will not run.
    0 Kudos