Basic Structure of a SQL Script Procedure

The basic structure of a SQL Script procedure begins with the word PROCEDURE, followed by the name of the procedure, an open parenthesis, and a closed parenthesis. Next is a block that begins with the word BEGIN and ends with the word END. The code for the procedure is placed between the BEGIN and END statements.

Syntax

PROCEDURE myProcedure()
    BEGIN
    -- Add your code here
    END

Commenting SQL Script Code

A line that begins with two dashes ( -- ) is a comment (annotation) line. Comment lines are not executed.

Another way of commenting, similar to the style followed in Java programming, is shown in the following example:

PROCEDURE myProc2()
    BEGIN
     /*
     * This is a multiline comment
     */
        DECLARE x INTEGER; -- This is a comment
        CALL /shared/procedures/aProcedure(x /* param1*/);
    END

SQL Script Statement Delimiter

The statement delimiter is a semicolon ( ; ).