Interactive SQL allows you to type SQL commands or run command files using the dbisql utility. dbisql also provides feedback about the number of rows affected, the time required for each command, the execution plan of queries, and any error messages.
The syntax for dbisql is:
dbisql [ option] [ dbisql_command | command_file ]
If you include dbisql_command, Interactive SQL executes the command. You can also specify a command file name. If you do not specify dbisql_command or command_file, Interactive SQL enters interactive mode, where you can type a command into a command window.
Exit codes are 0 (success) or non-zero (failure).
Table 1-1 describes the command-line options available for dbisql.
Option |
Description |
---|---|
-c “keyword=value” |
Supply database connection parameters |
-d delimiter |
Use the given string as the command delimiter. |
-d1 |
Print statements as they are executed (command-prompt mode only). |
-datasource dsn_name |
Specify an ODBC data source to connect to. |
-f file_name |
Open (without running) the file called file_name. |
-host host_name |
Specify the host_name or IP address of the machine running a database server. |
-nogui |
Run in command-prompt mode. |
-onerror {continue | exit} |
Override the ON_ERROR option for all users. |
-port port_number |
Look on the specified port number for the database server. |
-q |
Quiet Mode – do not display messages or windows (Note that this does not suppress error messages). |
-x |
Syntax check only; no commands executed. |
-c – If Interactive SQL cannot connect, it displays a dialog where you can enter the connection parameters.
-d – Quotation marks around the delimiter are optional, but are required when the command shell itself interprets the delimiter in some special way.
Command delimiters are used for all connections in that Interactive SQL session, regardless of the setting stored in the database (for the user, or the public setting).
-d1 – (The final character is a number 1, not a lower-case L). Interactive SQL echoes all statements it executes to the Command window. This can be useful for debugging SQL scripts, or when Interactive SQL is processing a long SQL script.
-f – Open (but do not run) the file called filename. The file name can be enclosed in quotation marks, and must be enclosed in quotation marks if the file name contains a blank. If the file does not exist, or if itís really a directory instead of a file, Interactive SQL prints an error message to the console and then quits. If the file name does not include a full drive and path specification, it is assumed to be relative to the current directory.
-host – Specify the hostname or IP address of the computer on which the database server is running. You can use the name “localhost” to represent the current machine.
-nogui – Run Interactive SQL in a command-prompt mode, with no windowed user interface. This is useful for batch operations. If you specify either dbisql-command or command-file, then -nogui is assumed.
In this mode, Interactive SQL sets the program exit code to indicate success or failure. On Windows operating systems, the environment variable ERRORLEVEL is set to the program exit code. The exit codes are as follows:
Program exit code |
Description |
---|---|
0 |
Success |
1 |
General failure. At some point, a SQL or Interactive SQL statement did not execute successfully and the user chose to stop executing SQL statements. Alternatively, Interactive SQL noted an internal error. |
5 |
The user terminated interactive SQL. When an error occurs during execution, the user is prompted to ignore it, stop, or exit Interactive SQL. If the user opts to exit, the program returns code 5. Code 5 is also returned if an error occurs and the Interactive SQL option ON_ERROR is set to EXIT. |
9 |
Unable to connect. |
255 |
Bad command. The command contained incomplete or invalid options. |
-onerror – Controls what happens if an error is encountered while reading statements from a command file. This option overrides the ON_ERROR setting. It is useful when using Interactive SQL in batch operations.
-port – Specify the port number on which the database server is running.
-q – Do not display output messages. This is useful only if you start Interactive SQL with a command or command file. Note that specifying this option does not suppress error messages. Syntax check only (-x) Scan commands but do not execute them. This is useful for checking long command files for syntax errors.