rkgarimella9
Posts: 12
Joined: Fri Nov 23, 2018 3:12 am

Run SQL Scripts based on Condition of Output

Hi Team,

I need some help in the following scenario.

I've got couple of SQL Scripts that I'm using in my installer to run. Everything's fine. But recently, with a new requirement, I had to precheck to see if the Database is already created or not and then run the scripts that i've mentioned above. So, I've got a new PreCheckDB Sql Script file to do a simple select and return either 0 or 1.

Would like to know how can I configure the whole thing to first run the PreCheckDB.sql first and then read the output value from that query and then based on the condition run the other two sql scripts.

Thanks,
Ravi
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Run SQL Scripts based on Condition of Output

Hello Ravi,

In what regards the execution of the scripts, they are executed in the order they appear in the tree (top-down).

In what regards your second question, that can be achieved through an SQL Query. Now let me please explain the main differences between an SQL Script and an SQL Query.

- SQL Scripts are only executed during the deferred execution time (during the "Install Execution Stage" phase). This is the reason why they are executed in the order they appear in the tree.

- SQL Queries can be executed whenever you want them to be executed. An SQL query can be triggered by scheduling the associated custom action in the install execution stage or by directly invoking the custom action with a published event.

Aside from the differences presented above, another main difference is the fact that the SQL Query can also save the results of the interrogation in a property (exactly as you need), while an SQL Script can not do that.

For more information about SQL Queries, you can have a look on our "SQL Query Tab" article which I think you may find useful.

Also, the results are usually stored into a ComboBox or a ListBox, so I think you may find useful the "Working with Windows Installer ComboBox and ListBox controls" article as well.

Hope this helps.

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”