Parameter passing conventions for stored procedures and UDFs

The CALL statement and a function call can pass arguments to programs written in all supported host languages and REXX procedures.

Each language supports different data types that are tailored to it, as shown in the following tables. The SQL data type is contained in the leftmost column of the following table. Other columns in that row contain an indication of whether that data type is supported as a parameter type for a particular language. If the column is blank, the data type is not supported as a parameter type for that language. A host variable declaration indicates that DB2® SQL for iSeries™ supports this data type as a parameter in this language. The declaration indicates how host variables must be declared to be received and set properly by the procedure or function. When calling an SQL procedure or function, all SQL data types are supported so no column is provided in the table.

Table 1. Data types of parameters
SQL data type C and C++ CL COBOL for iSeries and ILE COBOL for iSeries
SMALLINT short N/A PIC S9(4) BINARY
INTEGER long N/A PIC S9(9) BINARY
BIGINT long long N/A PIC S9(18) BINAR

Note: Only supported for ILE COBOL for iSeries.

DECIMAL(p,s) decimal(p,s) TYPE(*DEC) LEN(p s) PIC S9(p-s)V9(s) PACKED-DECIMAL

Note: Precision must not be greater than 18.

NUMERIC(p,s) N/A N/A PIC S9(p-s)V9(s) DISPLAY SIGN LEADING SEPARATE

Note: Precision must not be greater than 18.

REAL or FLOAT(p) float N/A COMP-1

Note: Only supported for ILE COBOL for iSeries.

DOUBLE PRECISION or FLOAT or FLOAT(p) double N/A COMP-2

Note: Only supported for ILE COBOL for iSeries.

CHARACTER(n) char ... [n+1] TYPE(*CHAR) LEN(n) PIC X(n)
VARCHAR(n) char ... [n+1] N/A Varying-Length Character String
VARCHAR(n) FOR BIT DATA VARCHAR structured form N/A Varying-Length Character String
CLOB CLOB structured form N/A CLOB structured form

Note: only supported for ILE COBOL for iSeries.

GRAPHIC(n) wchar_t ... [n+1] N/A PIC G(n) DISPLAY-1 or PIC N(n)

Note: Only supported for ILE COBOL for iSeries.

VARGRAPHIC(n) VARGRAPHIC structured form N/A Varying-Length Graphic String

Note: Only supported for ILE COBOL for iSeries.

DBCLOB DBCLOB structured form N/A DBCLOB structured form

Note: only supported for ILE COBOL for iSeries.

BINARY BINARY structured form N/A BINARY structured form
VARBINARY VARBINARY structured form N/A VARBINARY structured form
BLOB BLOB structured form N/A BLOB structured form

Note: only supported for ILE COBOL for iSeries.

DATE char ... [11] TYPE(*CHAR) LEN(10) PIC X(10)

Note: for ILE COBOL for iSeries only, FORMAT DATE.

TIME char ... [9] TYPE(*CHAR) LEN(8) PIC X(8)

Note: for ILE COBOL for iSeries only, FORMAT TIME.

TIMESTAMP char ... [27] TYPE(*CHAR) LEN(26) PIC X(26)

Note: for ILE COBOL for iSeries only, FORMAT TIMESTAMP.

ROWID ROWID structured form N/A ROWID structured form
DataLink N/A N/A N/A
Indicator Variable short N/A PIC S9(4) BINARY
Table 2. Data types of parameters
SQL data type Java™ parameter style JAVA Java parameter style DB2GENERAL PL/I
SMALLINT short short FIXED BIN(15)
INTEGER int int FIXED BIN(31)
BIGINT long long N/A
DECIMAL(p,s) BigDecimal BigDecimal FIXED DEC(p,s)
NUMERIC(p,s) BigDecimal BigDecimal N/A
REAL or FLOAT(p) float float FLOAT BIN(p)
DOUBLE PRECISION or FLOAT or FLOAT(p) double double FLOAT BIN(p)
CHARACTER(n) String String CHAR(n)
VARCHAR(n) String String CHAR(n) VAR
VARCHAR(n) FOR BIT DATA byte[ ] com.ibm.db2.app.Blob CHAR(n) VAR
CLOB java.sql.Clob com.ibm.db2.app.Clob CLOB structured form
GRAPHIC(n) String String N/A
VARGRAPHIC(n) String String N/A
DBCLOB java.sql.Clob com.ibm.db2.app.Clob DBCLOB structured form
BINARY byte[ ] com.ibm.db2.app.Blob BINARY structured form
VARBINARY byte[ ] com.ibm.db2.app.Blob VARBINARY structured form
BLOB java.sql.Blob com.ibm.db2.app.Blob BLOB structured form
DATE Date String CHAR(10)
TIME Time String CHAR(8)
TIMESTAMP Timestamp String CHAR(26)
ROWID byte[] com.ibm.db2.app.Blob ROWID structured form
DataLink N/A N/A N/A
Indicator Variable N/A N/A FIXED BIN(15)
Table 3. Data types of parameters
SQL data type REXX RPG ILE RPG
SMALLINT N/A Data structure that contains a single sub-field. B in position 43, length must be 2, and 0 in position 52 of the sub-field specification. Data specification. B in position 40, length must be <= 4, and 00 in positions 41-42 of the sub-field specification.

or

Data specification. I in position 40, length must be 5, and 00 in positions 41-42 of the sub-field specification.
INTEGER numeric string with no decimal (and an optional leading sign) Data structure that contains a single sub-field. B in position 43, length must be 4, and 0 in position 52 of the sub-field specification. Data specification. B in position 40, length must be <=09 and >=05, and 00 in positions 41-42 of the sub-field specification.

or

Data specification. I in position 40, length must be 10, and 00 in positions 41-42 of the sub-field specification.
BIGINT N/A N/A Data specification. I in position 40, length must be 20, and 00 in positions 41-42 of the sub-field specification.
DECIMAL(p,s) numeric string with a decimal (and an optional leading sign) Data structure that contains a single sub-field. P in position 43 and 0 through 9 in position 52 of the sub-field specification. or A numeric input field or calculation result field. Data specification. P in position 40 and 00 through 31 in positions 41-42 of the sub-field specification.
NUMERIC(p,s) N/A Data structure that contains a single sub-field. Blank in position 43 and 0 through 9 in position 52 of the sub-field specification. Data specification. S in position 40, or Blank in position 40 and 00 through 31 in position 41-42 of the sub-field specification.
REAL or FLOAT(p) string with digits, then an E, (then an optional sign), then digits N/A Data specification. F in position 40, length must be 4.
DOUBLE PRECISION or FLOAT or FLOAT(p) string with digits, then an E, (then an optional sign), then digits N/A Data specification. F in position 40, length must be 8.
CHARACTER(n) string with n characters within two apostrophes Data structure field without sub-fields or data structure that contains a single sub-field. Blank in position 43 and 52 of the sub-field specification. or A character input field or calculation result field. Data specification. A in position 40, or Blank in position 40 and 41-42 of the sub-field specification.
VARCHAR(n) string with n characters within two apostrophes N/A Data specification. A in position 40, or Blank in position 40 and 41-42 of the sub-field specification and the keyword VARYING in positions 44-80.
VARCHAR(n) FOR BIT DATA string with n characters within two apostrophes N/A Data specification. A in position 40, or Blank in position 40 and 41-42 of the sub-field specification and the keyword VARYING in positions 44-80.
CLOB N/A N/A CLOB structured form
GRAPHIC(n) string starting with G', then n double byte characters, then ' N/A Data specification. G in position 40 of the sub-field specification.
VARGRAPHIC(n) string starting with G', then n double byte characters, then ' N/A Data specification. G in position 40 of the sub-field specification and the keyword VARYING in positions 44-80.
DBCLOB N/A N/A DBCLOB structured form
BINARY N/A N/A BINARY structured form
VARBINARY N/A N/A VARBINARY structured form
BLOB N/A N/A BLOB structured form
DATE string with 10 characters within two apostrophes Data structure field without sub-fields or data structure that contains a single sub-field. Blank in position 43 and 52 of the sub-field specification. Length is 10. or A character input field or calculation result field. Data specification. D in position 40 of the sub-field specification. DATFMT(*ISO) in position 44-80.
TIME string with 8 characters within two apostrophes Data structure field without sub-fields or data structure that contains a single sub-field. Blank in position 43 and 52 of the sub-field specification. Length is 8. or A character input field or calculation result field. Data specification. T in position 40 of the sub-field specification. TIMFMT(*ISO) in position 44-80.
TIMESTAMP string with 26 characters within two apostrophes Data structure field without sub-fields or data structure that contains a single sub-field. Blank in position 43 and 52 of the sub-field specification. Length is 26. or A character input field or calculation result field. Data specification. Z in position 40 of the sub-field specification.
ROWID N/A N/A ROWID structured form
DataLink N/A N/A N/A
Indicator Variable numeric string with no decimal (and an optional leading sign). Data structure that contains a single sub-field. B in position 43, length must be 2, and 0 in position 52 of the sub-field specification. Data specification. B in position 40, length must be <=4, and 00 in positions 41-42 of the sub-field specification.
Related information
Embedded SQL programming
Java SQL routines