Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Reference » SQL Statements

RAISERROR statement [T-SQL] Next Page

READ statement [Interactive SQL]

Use this statement to read Interactive SQL statements from a file.


READ [ ENCODING encoding ] file-name [ parameter ] ...

encoding : identifier or string


The READ statement reads a sequence of Interactive SQL statements from the named file. This file can contain any valid Interactive SQL statements, including other READ statements. READ statements can be nested to any depth. If the file name does not contain an absolute path, Interactive SQL searches for the file. Interactive SQL will first search the current directory, and then the directories specified in the environment variable SQLPATH, and then the directories specified in the environment variable PATH. If the named file has no file extension, Interactive SQL searches each directory for the same file name with the extension .sql.

The encoding argument allows you to specify the encoding that is used to read the file. The READ statement does not process escape characters when it reads a file. It assumes that the entire file is in the specified encoding.

If encoding is not specified, Interactive SQL determines the encoding that is used to read the file as follows, where encoding values occurring earlier in the list take precedence over those occurring later in the list:

For more information about Interactive SQL and encodings, see default_isql_encoding option [Interactive SQL].

Parameters can be listed after the name of the command file. These parameters correspond to the parameters named on the PARAMETERS statement at the beginning of the statement file (see PARAMETERS statement [Interactive SQL]). Parameter names must be enclosed in square brackets. Interactive SQL substitutes the corresponding parameter wherever the source file contains {parameter-name}, whereparameter-name is the name of the appropriate parameter.

The parameters passed to a command file can be identifiers, numbers, quoted identifiers, or strings. When quotes are used around a parameter, the quotes are put into the text during the substitution. Parameters that are not identifiers, numbers, or strings (contain spaces or tabs) must be enclosed in square brackets ([ ]). This allows for arbitrary textual substitution in the command file.

If not enough parameters are passed to the command file, Interactive SQL prompts for values for the missing parameters.



Side effects


See also
Standards and compatibility

The following are examples of the READ statement.

READ status.rpt '160'
READ birthday.sql [>= '1988-1-1'] [<= '1988-1-30']