602SQL Documentation Index  

CALL Statement - Calling a Procedure

procedure_call ::= CALL [DETACHED] [scheme.]name ([actual_parameter {, actual_parameter}  ]);
actual_parameter ::= key_parameter | pivotal_parameter
key_parameter ::= formal_parameter_name => expression
pivotal_parameter ::= expression

The CALL statement calls a procedure created by the CREATE PROCEDURE or DECLARE PROCEDURE statement. It can also be used to execute the following API functions: SQL_execute, Log_write, Free_deleted, or Set_sql_option.

It is possible to call a stored procedure from a different application, just prefix the procedure name with the application name and a dot. WARNING: procedures are compiled in the application context where it is stored, not in the calling application context. If the procedure calls a table not prefixed with the application name, then the table in the application where the procedure is stored will be used.

If the DETACHED keyword is specified, the procedure will run in a separate thread. Local or standard procedures may be run DETACHED.

Pivotal actual parameters are assigned to formal parameters specified in the procedure description based on its position (from left to right), while the key parameters are distinguished by the formal parameter name. Pivotal parameters must be specified before the key parameters.

The value of the IN parameter is set by the expression value. The type of the expression must correspond with the formal parameter. The OUT or IN-OUT actual parameter must be a variable or a column of the same type as the formal IN parameter.

602SQL Variations

SQL Properties in 602SQL Defined by Implementation


Let's have a procedure called PARAM with one IN parameter and one OUT parameter defined as follows:

  FROM Tab1
  WHERE dat = dt;

This procedure may be called from the 602SQL Client using the pivotal parameters, if we have the following variables defined : date (DATE type) and amount (INT type).

CALL Param(:<date, :>amount);

or using the key parameters:

CALL Param(res=>:>amount, dt=>:<date);