Entering content frame

Object documentation Batch File Locate the document in its SAP Library structure

Definition

SQLCLI can process in the background SQLCLI commands and SQL statements from a batch file. See Executing an SQLCLI Command (Page 9) and Executing an SQL Statement (Page 5).

Structure

The individual SQLCLI commands and SQL statements appear in individual rows and are separated by a separator.

Note

You can specify the separator used in the batch file between two SQL statements using the -c <separator> call option (Page 13). The default value is //

Caution

Do not enter additional spaces in the batch file. The following two separators, for example, are not identical for the database system:

//

<blank>//

Example

CREATE TABLE city
(zip                CHAR (5)    KEY CONSTRAINT zip BETWEEN '10000' AND '99999',
 name               CHAR(20)    NOT NULL,
 state              CHAR(2)     NOT NULL)
//
CREATE TABLE customer
(cno                FIXED (4)   KEY CONSTRAINT cno BETWEEN 1 AND 9999,
 title              CHAR (7)    CONSTRAINT title IN ('Mr', 'Mrs', 'Company'),
 firstname          CHAR (10)   ,
 name               CHAR (10)   NOT NULL,
 zip                CHAR (5)    CONSTRAINT zip BETWEEN '10000' AND '99999',
 address            CHAR (25)   NOT NULL,
 FOREIGN KEY (zip) REFERENCES city ON DELETE RESTRICT)
//
\dt customer
//
COMMIT

In this example, AUTOCOMMIT mode (External)is deactivated. To ensure that SQLCLI executes the SQL statements immediately after the batch file has been read, the batch file must contain an explicit COMMIT.

Note

However, AUTOCOMMIT mode is usually activated. In this case, the explicit COMMIT command is redundant.

 

Leaving content frame