Using the embedded CALL statement where no procedure definition exists
A static CALL statement without a corresponding CREATE PROCEDURE statement is processed with these rules.
- All host variable arguments are treated as INOUT type parameters.
- The CALL type is GENERAL (no indicator argument is passed).
- The program to call is determined based on the procedure name specified on the CALL, and, if necessary, the naming convention.
- The language of the program to call is determined based on information retrieved from the system about the program.
Example: Embedded CALL statement where no procedure definition exists
The following PL/I example shows an embedded CALL statement where no procedure definition exists:
DCL HV2 CHAR(10); : EXEC SQL CALL P2 (:HV2); :When the CALL statement is issued, SQL attempts to find the program based on standard SQL naming conventions. For the preceding example, assume that the naming option of *SYS (system naming) is used and that a DFTRDBCOL parameter is not specified on the Create SQL PL/I Program (CRTSQLPLI) command. In this case, the library list is searched for a program named P2. Because the call type is GENERAL, no additional argument is passed to the program for indicator variables.
If an indicator variable is specified on the CALL statement and its value is less than zero when the CALL statement is executed, an error results because there is no way to pass the indicator to the procedure.
Assuming program P2 is found in the library list, the contents of host variable HV2 are passed in to the program on the CALL and the argument returned from P2 is mapped back to the host variable after P2 has completed execution. For numeric constants passed on a CALL statement, the following rules apply:
Special registers specified on a dynamic CALL statement are passed as follows:
- All integer constants are passed as fullword binary integers.
- All decimal constants are passed as packed decimal values. Precision and scale are determined based on the constant value. For instance, a value of 123.45 is passed as a packed decimal(5,2). Likewise, a value of 001.01 is also passed with a precision of 5 and a scale of 2.
- All floating point constants are passed as double-precision floating point.
- CURRENT DATE
- Passed as a 10-byte character string in ISO format.
- CURRENT DEGREE
- Passed as a 5-byte character string.
- CURRENT TIME
- Passed as an 8-byte character string in ISO format.
- CURRENT TIMEZONE
- Passed as a packed decimal number with a precision of 6 and a scale of 0.
- CURRENT TIMESTAMP
- Passed as a 26-byte character string in IBM® SQL format.
- CURRENT SCHEMA
- Passed as an 128-byte varying length character string.
- CURRENT SERVER
- Passed as an 18-byte varying length character string.
- USER
- Passed as an 18-byte varying length character string.
- CURRENT PATH
- Passed as a 3483-byte varying length character string.
- SESSION_USER
- Passed as a 128-byte varying length character string.
- SYSTEM_USER
- Passed as a 128-byte varying length character string.
Parent topic:
Calling a stored procedure