SQL$HELP72.HLB  —  CALL  Simple Statement, Examples
    Example 1: Calling a stored procedure

    The following examples show the definition of a stored procedure,
    NEW_SALARY_PROC, and the nonstored procedure, CALL_NEW_SALARY,
    that invokes it with the simple statement CALL.

    SQL> ! The following shows the definition of the stored procedure:
    SQL> !
    SQL> CREATE MODULE NEW_SALARY_PROC
    cont>        LANGUAGE SQL
    cont>        PROCEDURE NEW_SALARY_PROC
    cont>                  (:ID CHAR (5),
    cont>                   :NEW_SALARY INTEGER (2));
    cont>         BEGIN
    cont>              UPDATE SALARY_HISTORY
    cont>                     SET SALARY_END = CURRENT_TIMESTAMP
    cont>                     WHERE EMPLOYEE_ID = :ID;
    cont>              INSERT INTO SALARY_HISTORY
    cont>                                 (EMPLOYEE_ID, SALARY_AMOUNT,
    cont>                                  SALARY_START, SALARY_END)
    cont>                          VALUES (:ID, :NEW_SALARY,
    cont>                                  CURRENT_TIMESTAMP, NULL);
    cont>         END;
    cont> END MODULE;
    SQL>

    The following example shows an excerpt of an SQL module that
    contains the nonstored procedure that calls the stored procedure.

       .
       .
       .
    PROCEDURE CALL_NEW_SALARY
        :ID CHAR(5),
        :ID_IND SMALLINT,
        :NEW_SALARY INTEGER (2),
        :NEW_SALARY_IND SMALLINT,
        SQLCODE;

        CALL NEW_SALARY_PROC (:ID, :NEW_SALARY );
       .
       .
       .

    Example 2: Calling a procedure in interactive SQL

    The following example shows that you use interactive SQL to
    invoke a stored procedure with the simple statement CALL:

    SQL> DECLARE :X INTEGER;
    SQL>  BEGIN
    cont>   SET :X = 0;
    cont> END;
    SQL> CALL P2 (10, :X);
Close Help