Opening Interactive SQL using the dbisql command-line utility

Syntax

dbisql [ options ] [ dbisql-command | command-file ]

Parameters

Table 2-1: dbisql options

Option

Description

-c "keyword=value; ..."

Supply database connection parameters.

-codepage codepage

Specify a code page 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 filename

Open (without running) the file called filename.

-host hostname

Specify the host name 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.

-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.

Usage

Exit codes are 0 (success) or non-zero (failure).

Interactive SQL requires that you set the QUOTED_IDENTIFIER database option ON since a number of database functions, including some statements, rely on this setting to function. Interactive SQL automatically sets this option ON when connecting to a database.

Interactive SQL does not accept @filename parameters.

dbisql-command | command-file If dbisql-command is specified, dbisql executes the command. You can also specify a command file name. If no dbisql-command is specified, dbisql enters 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 > Sybase IQ 15.1 > Interactive SQL Java.

-c "keyword=value; ..." Specify connection parameters. See Chapter 4, “Connection and Communication Parameters” in the System Administration Guide: Volume 1 for a description of the connection parameters. If you do not specify this option, the environment variable SQLCONNECT is used. If Interactive SQL cannot connect, you see a dialog box where you can enter the connection parameters.

NoteSybase recommends that, to avoid ambiguity, you always specify connection parameters for dbisql instead of relying on defaults. If you start more than one database on a server, for example, specify the database name, and in a network with subnets, specify the communications protocol parameter with host number. See Chapter 3, “Sybase IQ Connections” in the System Administration Guide: Volume 1.

-codepage Specify the code page to use when reading or writing files. The default code page is 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:

-codepage 297

-d Specify a command delimiter. Quotation marks around the delimiter are optional, except 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). You may find this feedback useful if you are 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. By default, Sybase IQ data sources are configured to use TCP/IP.

-f filename Open (but do not run) the file called filename. You must enclose the file name in quotes if the file name contains a blank; otherwise, quotes are optional. If the file does not exist, or if it is a directory instead of a file, Interactive SQL prints an error message to the console and quits. If the file name does not include a full drive and path specification, the file is assumed to be relative to the current directory.

-host Specify the host name 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 jConnect JDBC driver to connect to the database. For most circumstances, Sybase recommends this driver.

-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 -nogui 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.

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 the error, stop, or exit Interactive SQL. If the user opts to exit, the program returns code 5.

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.

-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.

-x Scan commands but do not execute them. You may find this option useful for checking long command files for syntax errors.

Examples

The examples below show how to use dbisql at the system command prompt level. The rest of the dbisql sections in this chapter discuss how to use dbisql interactively.

dbisql -c "uid=DBA;pwd=sql" -onerror exit mycom.sql
dbisql -c "uid=DBA;pwd=sql" grant connect to joe identified by passwd

See also

For detailed descriptions of SQL statements and dbisql commands, see Chapter 1, “SQL Statements” in Reference: Statements and Options.