berqo127
Posts: 21
Joined: Tue Aug 06, 2019 1:35 pm

Running SQL Query

Hi,

I've created predefined connection and query that create DB indexes (I used quey and not sql script becouse I need to play with the sequence of the script execution stage).
the installer completed succesfully but the script didn't execute.

please advice,
Shlomi
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Running SQL Query

Hello Shlomi,
the installer completed succesfully but the script didn't execute.
The query probably executed, but it did not work. Please keep in mind that a query can be used only to interrogate the database. You can not create indexes using a query, a script will be needed for such a task.

Please have a look on our "Using an SQL query to interrogate SQL databases" article for more information about SQL queries.

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
berqo127
Posts: 21
Joined: Tue Aug 06, 2019 1:35 pm

Re: Running SQL Query

Hi,

I tried to use SQL script but realized that I cant impact the execution order and prior to executing the SQL script I need to run EXE that creates the DB.

Thanks,
Shlomi
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Running SQL Query

Hello Shlomi,
I tried to use SQL script but realized that I cant impact the execution order
Indeed, you are right. SQL Scripts can only be executed during the deferred stage. However, unfortunately, I am afraid that an SQL Query can only be used to interrogate a database, not to create it.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
berqo127
Posts: 21
Joined: Tue Aug 06, 2019 1:35 pm

Re: Running SQL Query

Thanks for the response.
So if I need to run exe first that creates the database and than I need to run SQL script for creating indexes how do you suggest to implement that ?
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Running SQL Query

Hello,

If you have an .EXE that creates the database, then you can launch that .EXE during the installation. The custom action that launches this .EXE should be scheduled after the "InstallFiles" standard action (the action that installs the files from the "Files and Folders" page. The reason behind this is the fact that the .EXE should exist on the target machine so we can launch it.) and before the "PatchFiles" standard action. The execution of the SQL scripts takes place after that, so everything should work just fine.

In order to achieve this, you can go to "Custom Actions" page --> under "Install Execution Stage" right click on any action group -->
"Show standard actions" --> "Add resources" --> select both "InstallFiles" and "PatchFiles".

After doing so, simply schedule your custom action between the above specified standard actions and change its execution time from "Immediately" to "When the system is being modified (deferred).

Hope this helps.

Best regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
berqo127
Posts: 21
Joined: Tue Aug 06, 2019 1:35 pm

Re: Running SQL Query

It did. Thanks!
Catalin
Posts: 6597
Joined: Wed Jun 13, 2018 7:49 am

Re: Running SQL Query

You are always welcome, Shlomi.

Glad I could help.

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

Return to “Common Problems”