dbisql [ options ] [ dbisql-command | command-file ]
Table 2-1: “dbisql options” lists the available options for dbisql.
Option |
Description |
---|---|
-c "keyword=value; ..." |
Supply database connection parameters |
-codepage codepage |
Specify a codepage to use when reading or writing files |
-d delimiter |
Use the given string as the command delimiter |
-d1 |
Print statements as they are executed [command-prompt mode only] |
-datasource dsn-name |
Supply an ODBC data source |
-f |
Open (without running) the file called filename. |
-host hostname |
Specify the hostname or IP address of the machine running a database server. |
-jConnect |
Use jConnect to connect to the database |
-nogui |
Run in command-prompt mode |
-ODBC |
Use the iAnywhere JDBC driver to connect to the database |
–onerror { continue | exit } |
Override the ON_ERROR option for all users |
-port portnumber |
Look on the specified port number for the database server. |
-q |
Run in quiet mode — No windows or messages. |
-x |
Run in syntax check mode — No commands executed. |
Note that for Sybase IQ 12, the Help menu item does not open online help for dbisql, but help is available in Sybase Central. In Sybase Central, choose Help → Sybase IQ Help, then click the Index tab. Type dbisql in the Topic or Keyword box and click the Go To button.
Exit codes are 0 (success) or non-zero (failure).
Interactive SQL requires that the QUOTED_IDENTIFIER database option be set to ON since a number of database functions, including some statements, rely on this setting to function properly. Interactive SQL automatically sets it ON when connecting to a database.
This utility does not accept @filename parameters.
dbisql-command | command-file If dbisql-command is specified, then dbisql executes the command. You can also specify a command file name. If no dbisql-command is specified, dbisql enters the interactive mode where you can type a command into a command window. From the Windows Start menu, you can enter interactive mode by selecting Programs → Sybase → Adaptive Server IQ 12.6 → Interactive SQL Java.
–c "keyword=value; ..." Specify connection parameters. See Chapter 4, “Connection and Communication Parameters” in the Sybase IQ System Administration Guide for a description of the connection parameters. If this option is not specified, the environment variable SQLCONNECT is used. If Interactive SQL cannot connect, you are presented with a dialog box where you can enter the connection parameters.
Sybase recommends that, to avoid ambiguity, you always specify connection parameters for dbisql instead of relying on defaults, whether you specify them in a command line or an initialization file such as .odbc.ini. If more than one database is started on a server, for example, you should specify the database name, and in a network with subnets, specify the communications protocol parameter with host number. For details, see Chapter 3, “Sybase IQ Connections” in the Sybase IQ System Administration Guide.
–codepage Specify the codepage to use when reading or writing files. The default code page is the default code page for the platform you are running on.
For example, on an English Windows machine, Interactive SQL uses the 1252 (ANSI) code page. If you want Interactive SQL to read files created using the 297 (IBM France) code page, specify the following option.
–codepage 297
For a list of supported code pages, see “Supported code pages” in Sybase IQ System Administration Guide.
–d Specify a command delimiter. Quotation marks around the delimiter are optional, but 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 (STDOUT). This can provide useful feedback for debugging SQL scripts, or when Interactive SQL is processing a long SQL script.
–datasource Specify an ODBC data source to connect to. You do not need to be using the iAnywhere JDBC driver to use this option. However, if the data source to which you are connecting is not configured to use TCP/IP, you must use the iAnywhere JDBC driver to connect. Sybase IQ data sources are configured to use TCP/IP by default.
–f filename 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 is 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.
–jConnect Use the Sybase jConnect JDBC driver to connect to the database. This is the method recommended in most circumstances.
–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 listed in Table 2-2: “dbisql program exit codes”.
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 |
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 line. The command line contained incomplete or invalid switches. |
–ODBC Connect using the iAnywhere JDBC driver. (The iAnywhere JDBC driver was formerly called the JDBC-ODBC bridge.)
–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.
For more information, see “ON_ERROR option [DBISQL]” in Sybase IQ Reference Manual.
–port Specify the port number on which the database server is running. The default port number for Sybase IQ is 2638.
–q Do not display output messages. This option is useful only if you start Interactive SQL with a command or command file. Specifying this option does not suppress error messages.
If you run Interactive SQL Java (dbisql) with the -q option and data extraction commands (primarily setting the option TEMP_EXTRACT_NAME1 to an output file) are in a command file, you must first set and make permanent the dbisql option “Show multiple result sets.” If this option is not set, the data extraction output file is not created.
To set the “Show multiple result sets” option, click Tools → Options → Results in the dbisql window, then check the box “Show multiple result sets” and click “Make permanent.”
–x Scan commands but do not execute them. This option is useful for checking long command files for syntax errors.
The examples in this section illustrate using dbisql at the system command prompt level. The rest of the dbisql sections in this chapter discuss how to use dbisql interactively.
The following command, entered at a system prompt, runs the command file mycom.sql against the current default server, using the user ID DBA and the password SQL. If there is an error in the command file, the process terminates.
dbisql -c "uid=DBA;pwd=SQL" –onerror exit mycom.sql
The following command, when entered on a single line at a command prompt, adds a user to the current default database:
dbisql -c "uid=DBA;pwd=SQL" grant connect to joe identified by passwd
For detailed descriptions of SQL statements and dbisql commands, see Chapter 6, “SQL Statements” in the Sybase IQ Reference Manual.