Command line processor CALL statement
Use the command line processor CALL statement to invoke stored procedures from the command line processor.
Use the following syntax for the command line processor CALL statement.
(1) >>-CALL--procedure-name-----------------------------------------> >--(--+---------------------------+--)------------------------->< | .-,---------------------. | | V (2) (3) (4) | | '---parameter-------------+-'
Notes:
- If you specify an unqualified stored procedure name, DB2® searches the schema list in the CURRENT PATH special register. DB2 searches this list for a stored procedure with the specified number of input and output parameters.
- Specify a question mark (?) as a placeholder for each output parameter.
- For non-numeric, BLOB, or CLOB input parameters, enclose each value in single quotation marks ('). The exception is if the data is a BLOB or CLOB value that is to be read from a file. In that case, use the notation file://fully qualified file name.
- Specify the input and output parameters in the order that they are specified in the signature for the stored procedure.
Example: Assume that the TEST.DEPT_MEDIAN
stored procedure was created with the following statement:
CREATE PROCEDURE TEST.DEPT_MEDIAN
(IN DEPTNUMBER SMALLINT, OUT MEDIANSALARY INT)
To invoke
the stored procedure from the command line processor, you can specify
the following CALL statement: CALL TEST.DEPT_MEDIAN(51, ?)
Assume
that the stored procedure returns a value of 25,000. The following
information is displayed by the command line processor: Value of output parameters
--------------------------
Parameter Name : MEDIANSALARY
Parameter Value : 25000
Example: Suppose
that stored procedure TEST.BLOBSP is defined with one input parameter
of type BLOB and one output parameter. You can invoke this stored
procedure from the command line processor with the following statement:
CALL TEST.BLOBSP(file:///tmp/photo.bmp,?)
The
command line processor reads the contents from /tmp/photo.bmp as the
input parameter. Alternatively, you can invoke this stored procedure
by specifying the input parameter in the CALL statement itself, as
in the following example:
CALL TEST.BLOBSP('abcdef',?)