Setting Up a Database Server Type Condition for SQL Scripts
InstallShield 2022
Project:This information applies to the following project types:
InstallShield enables you to create a single connection that targets both Microsoft SQL Server and MySQL and that has multiple SQL scripts specific to each database server technology. However, a connection is created based on whichever database type is detected first. Therefore, scripts are run only for the detected database type, and the scripts that are specific to the non-detected database server type fail. For example, if the run time detects a Microsoft SQL Server, then the scripts associated with Microsoft SQL Server run, and the scripts that are specific to MySQL fail.
As a workaround to this behavior, it is recommended that you set a condition in your SQL script so that a SQL scripting error occurs when the installation is running a non-detected database server type script. Then you can set up custom error handling for the scripting error and skip to the next script for the connection. The following instructions discuss how you can set this database server type condition for scripts.
To set up a database server type condition for a script that targets Microsoft SQL Server:
|
1.
|
In the View List under Server Configuration, click SQL Scripts. |
|
2.
|
In the SQL Scripts explorer, click the script file for which you are creating the condition. |
|
4.
|
Add the following statement at the beginning of the script: |
SELECT @@ROWCOUNT
|
5.
|
Click the Runtime tab. |
|
6.
|
In the Script Error Handling area, click the Custom button. The Custom Error Handling dialog box opens. |
|
7.
|
Click the Click here to add a new item row. |
|
8.
|
In the Error Number column, type 1193. This is the error number that MySQL returns when it does not have the specified system variable that you added at the beginning of the script. |
|
9.
|
In the Behavior column, click On Error, Goto Next Script. |
|
10.
|
In the Project Wide column, click No. |
To set up a database server type condition for a script that targets MySQL:
|
1.
|
In the View List under Server Configuration, click SQL Scripts. |
|
2.
|
In the SQL Scripts explorer, click the script file for which you are creating the condition. |
|
4.
|
Add the following statement at the beginning of the script: |
SELECT @@table_cache
|
5.
|
Click the Runtime tab. |
|
6.
|
In the Script Error Handling area, click the Custom button. The Custom Error Handling dialog box opens. |
|
7.
|
Click the Click here to add a new item row. |
|
8.
|
In the Error Number column, type 137. This is the error number that Microsoft SQL Server returns when it does not have the specified system variable that you added at the beginning of the script. |
|
9.
|
In the Behavior column, click On Error, Goto Next Script. |
|
10.
|
In the Project Wide column, click No. |