Previous Topic: Embedding SQL StatementsNext Topic: Placing an SQL Statement


Delimited, Continued, and Commented Statements

How You Delimit a Statement

When you embed an SQL statement in a CA ADS application program, you must use these statement delimiters:

Statement Delimiter Example

The following example shows the use of SQL statement delimiters:

EXEC SQL
  INSERT INTO DIVISION VALUES ('D07','LEGAL',1234)
END-EXEC.

The statement text can be on the same line as the delimiters.

Continuing Statements

You can write an SQL statement on more than one line if you do one of the following:

Continued Statement Example

----+----1----+----2----+----3----+----4----+----5----+----6----+----7—
EXEC SQL
   INSERT INTO SKILL VALUES (5678, 'TELEMARKETING', 'PRESENT SALES SCRIP
T OVER THE TELEPHONE, INPUT RESULTS')
END-EXEC.

How to Put Comments in SQL Statements

To include comments within SQL statements embedded in a CA ADS program, you can use the SQL comment characters, two consecutive hyphens (--), on an SQL statement line following the statement text.

Restrictions on Comments

SQL Comment Example

The following example shows two comments within an embedded SQL statement:

EXEC SQL
-- Perform update on active employees only
   UPDATE BENEFITS
     SET VAC_ACCRUED = VAC_ACCRUED + 10,   -- Add 10 hours vacation
         SICK_ACCRUED = SICK_ACCRUED + 1   -- Add 1 sick day
     WHERE EMP_ID IN
         (SELECT EMP_ID FROM EMPLOYEE
            WHERE STATUS = 'A')
END-EXEC.