

CA Datacom/DB SQL Preprocessors › Embedding SQL Statements in Host Programs › Rules for Coding Embedded SQL
Rules for Coding Embedded SQL
When you embed SQL statements in your host program, you must adhere to the following requirements:
- Exactly one SQL statement is allowed:
- In COBOL, between a pair of EXEC SQL and END-EXEC keywords.
- In PL/I and C, between the EXEC SQL and the terminating semicolon.
- In Assembler, for an EXEC SQL.
- In COBOL, BEGIN DECLARE SECTION and END DECLARE SECTION can only be used in the WORKING-STORAGE SECTION of your program.
- In COBOL, INCLUDE is not recognized by the ANSI standard.
- Host-variable requirements are:
- The maximum length allowed for host-variables for all languages is 32,765 bytes.
- In COBOL, all host-variables in your program must be declared before you code any DECLARE cursor-name CURSOR statement.
- In PL/I and C, a host-variable in your program must be declared in the source prior to its reference by an SQL statement, and you must determine the proper scope for host-variables.
- In Assembler, you must determine the proper scope for host-variables.
- for the C language, also see Rules for Coding Host-Variables in C.
- In COBOL, all other embedded SQL statements must be in the PROCEDURE DIVISION.
- To conform to the ANSI standards for embedded SQL, exactly one OPEN and one CLOSE must be coded:
- In COBOL, for each defined cursor name (each may be executed multiple times by the program). For extended mode SQL, at least one OPEN and one CLOSE must be coded for each defined cursor. This means that you are responsible for correctly coding the logic of OPEN and CLOSE.
- In PL/I and Assembler, for each cursor defined.
- In PL/I and Assembler, WHENEVER statements must appear in the source prior to their use. Any previous WHENEVER is in effect until replaced.
Copyright © 2014 CA.
All rights reserved.
 
|
|