INPUT
Go Up to isql Command Reference
Read and execute commands from the named file.
INPUT filename;
Argument | Description |
---|---|
<filename> |
Name of the file containing SQL statements and SQL commands |
Description: INPUT
reads commands from <filename> and executes them as a block. In this way, INPUT
enables execution of commands without prompting. <filename> must contain SQL statements or isql
commands.
Input files can contain their own INPUT
commands. Nesting INPUT
commands enables isql
to process multiple files. When isql
reaches the end of one file, processing returns to the previous file until all commands are executed.
The INPUT
command is intended for noninteractive use. Therefore, the EDIT
command does not work in input files.
Using INPUT
<filename> from within an isql
session has the same effect as using
-input
filename
from the command line.
Unless output is redirected using OUTPUT
, any results returned by executing filename appear on the screen.
You can optionally delimit the filename with double or single quotes. This allows you to use filenames with spaces in INPUT
statements.
Examples: For this example, suppose that file add.lst
contains the following INSERT
statement:
INSERT INTO COUNTRY (COUNTRY, CURRENCY)
VALUES ('Mexico', 'Peso');
To execute the command stored in add.lst
, enter:
INPUT add.lst;
For the next example, suppose that the file, table.lst
, contains the following SHOW
commands:
SHOW TABLE COUNTRY;
SHOW TABLE CUSTOMER;
SHOW TABLE DEPARTMENT;
SHOW TABLE EMPLOYEE;
SHOW TABLE EMPLOYEE_PROJECT;
SHOW TABLE JOB;
To execute these commands, enter:
INPUT table.lst;
To record each command and store its results in a file named table.out
, enter
SET ECHO ON;
OUTPUT table.out;
INPUT table.lst;
OUTPUT;