Previous Topic: Declaring SQLXQ1Next Topic: Defining Host Variables


Delimited, Continued, and Commented Statements

Using SQL Statement Delimiters

When you embed an SQL statement in a PL/I application program, you must use these statement delimiters:

An EXEC SQL delimiter must be preceded by either a PL/I label or the ; character.

The following example shows the use of SQL statement delimiters:

EXEC SQL  INSERT INTO DIVISION VALUES ('D07','LEGAL',1234) ;

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

Continuing Statements

You can write SQL statements on one or more lines. No special character is required to show that a statement continues on the next line if you split the statement before or after any keyword, value, or delimiter.

Inserting SQL Comments

To include comments within SQL statements embedded in a PL/I program, you can:

A comment that begins with the SQL comment characters (--) terminates at the end of the line (column 72).

You cannot use SQL comment characters to insert a comment in the middle of a string constant or delimited identifier.

The following example shows both methods of inserting 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') ;