READ Statement [Interactive SQL]

Reads Interactive SQL (dbisql) statements from a file.

Syntax

READ filenameparameter ] …

Examples

Usage

The READ statement reads a sequence of Interactive SQL statements from the named file. This file can contain any valid Interactive SQL statement, including other READ statements, which can be nested to any depth.

To find the command file, Interactive SQL first searches the current directory, then the directories specified in the environment variable SQLPATH, then the directories specified in the environment variable PATH. If the named file has no file extension, Interactive SQL also searches each directory for the same file name with the extension .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. Interactive SQL then substitutes the corresponding parameter wherever the source file contains:

{ parameter-name }

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

SQL character literals, including character data, passed as parameters to a READ statement should be enclosed in quotes.

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

The READ statement also supports an ENCODING clause, which lets you 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. When running Interactive SQL, the encoding that is used to read the data is determined in the following order:
  1. The encoding specified by the ENCODING clause (if this clause is specified).
  2. The encoding specified by the byte order mark (BOM) in the file (if a BOM is specified).
  3. The encoding specified with the default_isql_encoding option (if this option is set).
  4. The default encoding for the platform you are running on. On English Windows computers, the default encoding is 1252.

Standards

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not applicable.

Permissions

None

Related reference
DEFAULT_ISQL_ENCODING Option [Interactive SQL]
PARAMETERS Statement [Interactive SQL]