3. Embedded SQL for COBOL : Embedded SQL Statement Syntax for COBOL : The Create Procedure Statement
 
Share this page                  
The Create Procedure Statement
The create procedure statement, according to the SQL Reference Guide, has languageā€‘specific syntax rules for line continuation, string literal continuation, comments, and the final terminator. These syntax rules follow the rules this section discusses -- for example, the final terminator is end-exec. Regardless of the number of statements inside the procedure body, the preprocessor treats the create procedure statement as a single statement, and, when you use it as an embedded SQL/COBOL statement, you must use end-exec to terminate it. In addition, terminate all statements within the body of the procedure with a semicolon.
The following example shows a create procedure statement that follows the embedded SQL/COBOL syntax rules:
EXEC SQL
  CREATE PROCEDURE proc (parm INTEGER) AS
    DECLARE
            var INTEGER;
    BEGIN
* COBOL comment line
      IF parm > 10 THEN
      MESSAGE 'COBOL strings can continue (use hyphen)
-        ' over lines';
      INSERT INTO tab VALUES (:parm);
      ENDIF;
    END
END-EXEC.