Process Extended Dynamic SQL (QSQPRCED) API


  Required Parameter Group:


  Optional Parameter Group 1:


  Default Public Authority: *USE

  Threadsafe: Conditional; see Usage Notes.

The Process Extended Dynamic SQL (QSQPRCED) API provides functions to process extended dynamic SQL statements in an SQL package object.


Authorities and Locks

Creating an SQL package requires that you have *ADD and *READ authority to the library that will contain the package. Using an existing SQL package requires that you have *OBJOPR and *READ authority to the package. To use the PREPARE function of the API, you must have *OBJOPR and *ADD authority to the package. To use a sort sequence table, you must have *USE authority to the table and *EXECUTE authority to the library containing the table. To delete a specified package, you must have *OBJEXIST authority to the package and *EXECUTE authority to the library containing the package.


Required Parameter Group

SQL communications area
OUTPUT; CHAR(136)

This is used for returning diagnostic information. It includes the SQLCODE variable, indicating whether an error has occurred. If SQLCODE has a value of 0 after a call to this API, the function was successful.

You should have this space declared in the program that calls this API. This parameter is considered output because the API uses the space to pass back information. The format of the structure is standard and can be included using the INCLUDE SQLCA statement in an SQL program. It is described more completely in the SQL programming and DB2® for IBM® i SQL reference topic collections.

SQL descriptor area
INPUT; CHAR(*)

This is used for you to pass information about the variables being used on a specific SQL statement. The SQLDA is used for passing the address, data type, length, and coded character set identifier (CCSID)for variables on an OPEN, EXECUTE, FETCH, or DESCRIBE function.

The format of the structure is standard and can be included using the INCLUDE SQLDA statement in an SQL program. It is described more completely in the SQL programming and DB2 for i SQL reference topic collections.

Function template format
INPUT; CHAR(8)

The format of the function template being used. The possible values are:


For more information, see SQLP0100 Format, SQLP0110 Format, SQLP0200 Format, SQLP0210 Format, SQLP0300 Format, SQLP0310 Format, SQLP0400 Format, SQLP0410 Format or SQLP0500 Format.

Function template
INPUT; CHAR(*)

A structure that determines the function to perform, the requested statement to process, and the SQL package to be used. This also contains the text of the statement, which is required for the PREPARE function. For the format of this parameter, see SQLP0100 Format, SQLP0110 Format, SQLP0200 Format, SQLP0210 Format, SQLP0300 Format, SQLP0310 Format, SQLP0400 Format, SQLP0410 Format or SQLP0500 Format.

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Optional Parameter Group 1

SQL statement output
OUTPUT; CHAR(*)

You should have this space declared in the program that calls this API. This parameter is considered output because the API uses the space to pass back information.

For function D, this is used for receiving SQL diagnostic information from the SQL diagnostic area. The SQL diagnostic area contains information about an SQL statement (other then a GET DIAGNOSTIC statement) that was executed prior to invoking the API.

The format of the data received in this space depends on the type of diagnostic item(s) being retrieved. You can specify statement, condition, or connection information item types to be retrieved on SQLP0500 Format template. For detailed description of the format of the retrieved data specific for an information item type, see Diagnostic Information Data Format.

This parameter is required for function D.

For functions other than D, this is an optional parameter that returns a structure with output information about the SQL statement. The number of bytes available must be set on input to the number of bytes available for the structure.

Length of SQL statement output
INPUT; BINARY(4)

The length of SQL statement output.

This parameter is required for function D and it must be specified for this function with the minimum value of 8. If specified for other functions, it must have a minimum value of 16.

SQLP0100 Format

The following shows the format of the function template parameter for the SQLP0100 format. For detailed descriptions of the fields in the table, see Field Descriptions.

SQLP0110 Format

The following shows the format of the function template parameter for the SQLP0110 format. For detailed descriptions of the fields in the table, see Field Descriptions.



SQLP0200 Format

The following shows the format of the function template parameter for the SQLP0200 format. For detailed descriptions of the fields in the table, see Field Descriptions.

SQLP0210 Format

The following shows the format of the function template parameter for the SQLP0210 format. For detailed descriptions of the fields in the table, see Field Descriptions.


SQLP0300 Format

The following shows the format of the function template parameter for the SQLP0300 format. For detailed descriptions of the fields in the table, see Field Descriptions.

SQLP0310 Format

The following shows the format of the function template parameter for the SQLP0310 format. For detailed descriptions of the fields in the table, see Field Descriptions.


SQLP0400 Format

The following shows the format of the function template parameter for the SQLP0400 format. For detailed descriptions of the fields in the table, see Field Descriptions.

SQLP0410 Format

The following shows the format of the function template parameter for the SQLP0410 format. For detailed descriptions of the fields in the table, see Field Descriptions.



SQLP0500 Format

The following shows the format of the function template parameter for the SQLP0500 format. For detailed descriptions of the fields in the table, see Field Descriptions.



Field Descriptions

Allow copy of data. Whether a copy of the data can be used in a SELECT statement. The valid values follow:


The allow copy of data value is required for function 1. It is ignored for other functions.

Allow blocking. Whether the database manager can use record blocking, and the extent to which blocking can be used for read-only cursors. The valid values follow:


The allow blocking value is required for function 1. It is ignored for other functions.

Autocommit Option. When using a connection handle with SQL Server Mode, the autocommit option can be used to direct the database to handle commitment control for the connection. The valid values follow:


When requested, the database will commit or rollback activity in the QSQSRVR server job after every SQL statement operation sent by the client, when that operation performs some committable work. No commit or rollback occurs after fetch operations. If the SQLCODE indicates a failure, the database will rollback the transaction. If the SQLCODE indicates success, the transaction will be committed.

When commitment control is set to *NONE, the database upgrades the commitment control level to *CHG, in the corresponding QSQSRVR job over the span of that operation.

When the connection handle is set to 0, this field must be set to '0'. This function is only valid for SQLP0310 Format and SQLP0410 Format.

Blocking factor. The number of records to be passed on a multiple row FETCH request. The same number should be used on the OPEN and the FETCH request. The blocking factor is required for functions 4 and 5. It is ignored for other functions.

Close file name. The name of the file for which all pseudo-closed open data paths should be closed. The file name must be the system file name. It cannot be an SQL long table name. If all pseudo-closed open data paths for the job are to be closed, the close file name and the close library name should be specified as *ALL. The close file name is required for function B. It is ignored for other functions.

If the close library name is *NUMBER or *THRESHOLD, then the first 4 bytes of close file name should contain an integer value. For *NUMBER, the value indicates the number of pseudo-closed cursors to close. For *THRESHOLD, the value indicates the threshold of pseudo-closed cursors that should remain following the closing of pseudo-closed cursors.

Close library name. The library of the close file name. If the close file name is specified as *ALL, the close library name should be *ALL as well. The close library name is required for function B. It is ignored for other functions.

*NUMBER indicates to close a specified number of pseudo-closed cursors. *THRESHOLD indicates to continue closing pseudo-closed cursors until a specified threshold is reached.

Commitment control. The commit level to be used. The possible values are:


The commitment control value is required for function 1. It is ignored for other functions.

Concurrent access resolution. The concurrent access resolution for the statement.

The possible values are :

This field is only valid for SQLP0310 Format and SQLP0410 Format.

Condition number. The number that identifies a condition for which diagnostic information items are to be retrieved from the SQL diagnostic area. See Key Values and Data Types of Condition Diagnostic Information Items for a list of the keys of the condition information item types that may be retrieved for the condition. See Key Values and Data Types of Connection Diagnostic Information Items for a list of the keys of the connection information item types that may be retrieved for the condition.

Connection Handle. The connection handle allows SQL Server Mode users to have a one-to-one correspondence with a specific QSQSRVR prestart job in the QSYSWRK subsystem.

When the negated connection handle is passed as input, serialization within the job is not held during the execution of the work handed off to the QSQSRVR job. Using the negated connection handle allows an application to achieve parallel execution across threads which are using different connection handles. If the connection handle were 14, it would be valid to input -14 if the user wanted parallel execution where other threads within this job would be allowed to execute when using a connection handle other than 14.

The Extended Dynamic Remote SQL (EDRS) APIs can be used to establish connections. Connect to EDRS Server (QxdaConnectEDRS) is used to initiate a connection to a server system. The connection handle returned by this API is valid only in the same job and activation group in which it was generated. A connection cannot span multiple jobs or activation groups. The Extended Dynamic Remote SQL (EDRS) APIs will utilize QSQSRVR jobs when SQL Server Mode is ON and a local connection is requested.

This input field is ignored when SQL Server Mode is not active. SQL Server Mode can be enabled within the job by calling the Change Job (QWTCHGJB) API. When connections are established, completion message SQL7908 is sent to the SQL Server Mode client joblog, indicating which QSQSRVR job is being used for that connection. The commitment definition is owned by the job that is indicated in this message.

This function is only valid for SQLP0310 Format and SQLP0410 Format.

CURRENT CLIENT_USERID special register. The CURRENT CLIENT_USERID special register contains the value of the client user ID from the client information specified for the current connection. This field is only valid for SQLP0310 Format and SQLP0410 Format.

CURRENT CLIENT_WRKSTNNAME special register. The CURRENT CLIENT_WRKSTNNAME special register contains the value of the workstation name from the client information specified for the current connection. This field is only valid for SQLP0310 Format and SQLP0410 Format.

CURRENT CLIENT_APPLNAME special register. The CURRENT CLIENT_APPLNAME special register contains the value of the application name from the client information specified for the current connection. This field is only valid for SQLP0310 Format and SQLP0410 Format.

CURRENT CLIENT_PROGRAMID special register. The CURRENT CLIENT_PROGRAMID special register contains the value of the client program ID from the client information specified for the current connection. This field is only valid for SQLP0310 Format and SQLP0410 Format.

CURRENT CLIENT_ACCTNG special register. The CURRENT CLIENT_ACCTNG special register contains the value of the accounting string from the client information specified for the current connection. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Cursor Index. An optional input performance value for functions 4, 5, 6, and 8. The value from the SQL Statement Output from a previous QSQPRCED call for this cursor should be passed. By passing the cursor index the request will be processed faster, since the database manager will not need to search for the matching cursor. All other fields relevant to the cursor still need to be set. This function is only valid for SQLP0310 Format and SQLP0410 Format.

Cursor name. The name of the SQL cursor. Cursor Name or Extended Cursor Name is required for functions 4, 5, 6, and 8. It is ignored for other functions. The cursor name is limited to 18 characters when specifying it here. When using SQLP0310 Format and SQLP0410 Format, a longer cursor name can be specified by using the Length of Extended Cursor Name and Offset to Extended Cursor Name. When the Extended Cursor Name is specified, this field is ignored.

Date format. The format used when accessing date result columns. All output date fields are returned in the format you specify. For input date strings, the value you specify is used to determine whether the date is a valid format. The valid values are:


The date format is required for function 1. For function D, it must be set to X'000000'. It is ignored for other functions.

Date separator. The separator used when accessing date result columns. The valid values are:


The date separator is required for function 1. For function D, it must be set to X'00'. It is ignored for other functions.

Decimal point. The decimal point for numeric constants in SQL statements. The valid values are:


The decimal point is required for function 1. For function D, it must be set to X'00'. It is ignored for other functions.

Diagnostic information CCSID. CCSID of any CHAR data that is returned for the statement, condition, or connection diagnostic information. If 0 is specified, the data returned will be in the default job CCSID.

Direct map. Whether the data that is retrieved is to be moved directly into the user area. The possible values follow:


The direct map field is optional for function 5. The default value for direct map is N. It is ignored for all other functions.

Extended Cursor Name. The name of the SQL cursor. Cursor Name or Extended Cursor Name is required for functions 4, 5, 6, and 8. It is ignored for other functions.

Extended Indicator Option. Specifies whether statement prepared and executed from the package are enabled to use extended indicator support. The possible values are :


The extended indicator option is optional for function 1. It is ignored for other functions.

Extended Statement Name. The name of the SQL statement. Statement Name or Extended Statement Name is required for functions 2, 3, 4, 7, 9, and A. It is ignored for other functions.

Extended User-defined field. Up to 100 bytes of user-defined data that is inserted into the database performance monitor table. The data is only written to the table if you are collecting database performance monitor statistics by using the Start Database Monitor (STRDBMON) or the Start Performance Monitor (STRPFRMON) command. The user-defined field is optional for all functions. If this field is desired when you collect data, you should use it consistently for all functions.

Extended User-defined field length. The length of the extended user-defined field. The maximum length supported is 100. When the length contains zero, the user-defined field will be used instead of the extended user-defined field.

Function. The function being requested. The possible values follow:


Hex literal option. Option which allows Hex literals to be treated as binary data instead of treating them as character data. The Hex literal option is used for function 1. It is ignored for all other functions. The valid values follow:


Language identifier. The language identifier to be used when *LANGIDUNQ or *LANGIDSHR is specified for the sort sequence table name. The valid values follow:


The language identifier value is required for function 1 when a sort sequence value of *LNGIDUNQ or *LNGIDSHR is specified. It is ignored for other functions.

Length of Additional Fields. When used, this field indicates how much space exists for additional fields in the input template. This field is being used to allow the template to be extended to include additional input fields. Set this length to indicate the additional space being passed.

For example, to pass the Connection Handle and Autocommit Option input fields, the length should be set to at least 5. When the length exceeds the size of any defined fields, the additional input storage must be set to hex zeros.

This function is only valid for SQLP0310 Format and SQLP0410 Format.

Length of CURRENT CLIENT_USERID special register. The length of the CLIENT_USERID special register. The maximum supported length is 255. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of CURRENT CLIENT_WRKSTNNAME special register. The length of the CLIENT_WRKSTNNAME special register. The maximum supported length is 255. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of CURRENT CLIENT_APPLNAME special register. The length of the CLIENT_APPLNAME special register. The maximum supported length is 255. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of CURRENT CLIENT_PROGRAMID special register. The length of the CLIENT_PROGRAMID special register. The maximum supported length is 255. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of CURRENT CLIENT_ACCTNG special register. The length of the CLIENT_ACCTNG special register. The maximum supported length is 255. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of Extended Cursor Name. The length of the Extended Cursor Name. The maximum supported length is 128. When specifying the Extended Cursor Name, Cursor Name is ignored. Set this field to 0 when using Cursor Name. Cursor Name or Extended Cursor Name must be passed for functions 4, 5, 6, and 8. It is ignored for other functions. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Length of Extended Statement Name. The length of the Extended Statement Name. The maximum supported length is 128. When specifying the Extended Statement Name, Statement Name is ignored. Set this field to 0 when using Statement Name. Statement Name or Extended Statement Name must be passed for functions 2, 3, 4, 7, 9, and A. It is ignored for other functions. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Main program library name. The library of the main program.

Main program name. The name of the program representing the top program in the SQL application. When this program completes, all cursors are closed and the SQL environment goes away. This program must be on the stack or an error will occur (SQL0901). The main program name is required for all functions except 1. This allows you to control the boundary of the application. If you want to scope to an activation group, as opposed to the main program name, this can be done by specifying *ENDACTGRP for the main program name. This special value is only allowed for function 1. For all other functions, specify the actual main program name.

Main-program system pointer. A system pointer that has been resolved to point to the main program. This field is ignored if the use pointers field has not been set to Y. If the use pointers field is specified, this field is used in place of the main program name and main program library name.

Maximum Precision. Specifies the maximum precision (length) that should be used for decimal operations. The possible values follow:


The Maximum Precision is optional for function 1. The default is 1. It is ignored for all other functions.

Maximum Scale. Specifies the maximum scale (number of decimal positions to the right of the decimal point) that should be used for decimal operations. The value can range from 0 to the Maximum Precision.

The Maximum Scale is optional for function 1. The default is 31. It is ignored for all other functions.

Minimum Divide Scale. Specifies the minimum divide scale (number of decimal positions to the right of the decimal point) that should be used for both intermediary and result data types. The value can range from '0' to '9' and may not exceed the Maximum Scale.

The Minimum Divide Scale is optional for function 1. The default is '0'. It is ignored for all other functions.

Name check. Whether the statement names and cursor names are to be completely checked for valid name syntax. The possible values follow:


The name check field is optional. The default value for name check is Y. It is ignored for functions 1 and B.

Naming option. The naming convention used for naming objects in SQL statements. The valid values are:


The naming option is required for function 1. For function D, it must be set to X'000000'. It is ignored for other functions.

Number of rows for multiple row statement. When executing a multiple row INSERT or MERGE statement, this value indicates how many rows to process. The use of the SQLDA is similar to multiple row FETCH using SQLDA. See the DB2 for i SQL reference topic collection for instructions on how to set up the SQLDA to do multiple row FETCH. Refer to Multiple Row Statement Using SQLDA Setup Requirements for multiple row INSERT and MERGE requirements that are different from multiple row FETCH.

The prepared statement must be either a multiple row INSERT with a parameter marker specified for the number of rows, or a multiple row MERGE .

The number of rows is required for function 3 when the statement is a multiple row INSERT or MERGE. It is ignored for all other functions.

Number of statement, condition, or connection information items. The number of items specified in the statement, condition, or connection information item types list. If 0 is specified, no information items will be returned.

Offset to CURRENT CLIENT_USERID special register. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the CURRENT CLIENT_USERID special register field. Set this offset to 0 when the length of CURRENT CLIENT_USERID special register is zero. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to CURRENT CLIENT_WRKSTNNAME special register. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the CURRENT CLIENT_WRKSTNNAME special register field. Set this offset to 0 when the length of CURRENT CLIENT_WRKSTNNAME special register is zero. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to CURRENT CLIENT_APPLNAME special register. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the CURRENT CLIENT_APPLNAME special register field. Set this offset to 0 when the length of CURRENT CLIENT_APPLNAME special register is zero. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to CURRENT CLIENT_PROGRAMID special register. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the CURRENT CLIENT_PROGRAMID special register field. Set this offset to 0 when the length of CURRENT CLIENT_PROGRAMID special register is zero. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to CURRENT CLIENT_ACCTNG special register. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the CURRENT CLIENT_ACCTNG special register field. Set this offset to 0 when the length of CURRENT CLIENT_ACCTNG special register is zero. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to Extended Cursor Name. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the cursor name field. When specifying the cursor name using this field and Length of Extended Cursor Name, Cursor Name is ignored. Set this field to 0 when using Cursor Name. Cursor Name or Extended Cursor Name must be passed for functions 4, 5, 6, and 8. It is ignored for other functions.This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to Extended Statement Name. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the statement name field. When specifying the statement name using this field and Length of Extended Statement Name, Statement Name is ignored. Set this field to 0 when using Statement Name. Statement Name or Extended Statement Name must be passed for functions 2, 3, 4, 7, 9, and A. It is ignored for other functions. This field is only valid for SQLP0310 Format and SQLP0410 Format.

Offset to statement, condition, or connection information item type list. Offset from beginning of SQLP0500 Format to the list of statement, condition, or connection information item types.

Offset to statement text length and statement text. Offset from beginning of SQLP00110 Format, SQLP00210 Format, SQLP00310 Format, or SQLP00410 Format to the start of the statement text length field. The statement text should immediately follow the statement text length. This must be 0 for all functions other than 2, 3, 4, 7, 9, and A.

Offset to Extended User-defined field. Offset from beginning of SQLP00310 Format or SQLP00410 Format to the start of the extended user-defined field. When the offset is set to zero, the user-defined field will be used instead of the extended user-defined field.

Open options. The open options used on an SQL cursor. These are specified using the following bits:


For example, if a cursor is only for FETCH statements, the bit pattern should be '10000000'B or hex 80. If update capability is needed, the bit pattern should be '10100000'B. The syntax in the SQL statement takes precedence over the open options. This means that the FOR UPDATE OF and FOR FETCH ONLY clauses will be honored, even if they do not coincide with the requested open options. The open options are required for functions 2 and 4. They are ignored for other functions.

Position option. The positioning option that is used for a FETCH statement. For options other than NEXT, the cursor must have been opened as a scrollable cursor. The valid options are:


The position option is required for function 5. It is ignored for other functions.

Relative record. The number of rows forward or backward to move before retrieving data. A positive number means forward and a negative number, backward. This is required when using function 5 (FETCH) with a position option of FETCH RELATIVE. It is ignored for other options.

Reopen. Whether to allow a cursor that is currently open to be reopened. A reopen operation implicitly closes and opens the cursor. If a reopen operation is requested on a cursor that is currently closed, only an open operation is performed (no implicit close takes place). The valid values follow:


The reopen field is optional for function 4 with a default of 0. It is ignored for all other functions.

Use performance area. Use a performance area internally to store information about the invocation environment. This option is beneficial in environments where statements are run repeatedly. The valid values follow:


Reserved. All reserved fields must be set to X'00'.

Reuse SQLDA. Whether the SQLDA is being used again without changes. The possible values follow:


The reuse SQLDA field is optional for functions 3, 4, and 5. The default value for reuse SQLDA is N. It is ignored for all other functions.

Scrollable option. Specified if the cursor is scrollable. The cursor must be opened as scrollable if any FETCH options other than FETCH NEXT are used. The valid values are:


The scrollable option is required for function 4. It is ignored for other functions.

Sort sequence table name. The sort sequence table name to be used for string comparisons in SQL statements. The possible values follow:


The sort sequence table name value is required for function 1. It is ignored for other functions.

Sort sequence library name. The name of the sort sequence table can be qualified by one of the following library values:


The sort sequence library name value is required for function 1 when a table name is specified for the sort sequence table name value. It is ignored for other functions.

SQL package library name. The library of the package.

SQL package name. The name of the SQL package used as the repository for the extended dynamic SQL statements. The SQL package must not be a distributed SQL package created through the Create SQL Package (CRTSQLPKG) or the Create SQL xxx (CRTSQLxxx) commands. Attempted use of a distributed SQL package results in SQL0827. The SQL package name is required for all functions. Function 1 checks the specified package name for valid name syntax. An invalid name results in SQL7023.

SQL-package system pointer. A system pointer that has been resolved to point to the SQL package. This option is ignored if the use pointers field has not been set to Y. If the use pointers field is specified, this field is used in place of the SQL package name and SQL package library name.

Statement, condition, or connection information item types list. The list of statement, condition, or connection information types that are to be retrieved from the SQL diagnostic area. A unique key identifies each item type. For the list of the keys that may be specified for item types, see Key Values and Data Types of Statement Diagnostic Information Items, Key Values and Data Types of Condition Diagnostic Information Items, or Key Values and Data Types of Connection Diagnostic Information Items.

Any one or all of the individual diagnostic information item types may be specified in the list. A default value will be returned if the diagnostic item is currently not set in the SQL diagnostic area.

Statement Index. An optional input performance value for functions 2, 3, 4, 7, 9, and A. The value from the SQL Statement Ouput from a previous QSQPRCED call for this statement should be passed. By passing the statement index the request will be processed faster, since the database manager will not need to search for the matching statement. All other fields relevant to the statement still need to be set. This function is only valid for SQLP0310 Format and SQLP0410 Format.

Statement length. The length of the SQL statement text that follows. The statement length is required for function 2, 9 and A. It is ignored for other functions.

Statement length type. Whether the SQL statement text is preceded by a two-byte or a four-byte statement length. The valid values are:

Statement name. The name of the prepared SQL statement. Statement Name or Extended Statement Name is required for functions 2, 3, 4, 7, 9, and A. It is ignored for other functions. The statement name is limited to 18 characters when specifying it here. When using SQLP0310 Format and SQLP0410 Format, a longer statement name can be specified by using the Length of Extended Statement Name and Extended Statement Name Offset. When the Extended Statement Name is specified, this field is ignored.

Statement text. The SQL statement text that will be prepared. The statement text is required for function 2. It is ignored for other functions.

Statement text CCSID. The CCSID of the SQL statement text that will be prepared in this package. The statement text CCSID is optional for function 1. It is ignored for other functions. If the SQLP0100, SQLP0110, SQLP0200 or SQLP0210 formats are specified or if statement text CCSID is 0, the job CCSID is used.

Time format. The format used when accessing time result columns. All output time fields are returned in the format you specify. For input time strings, the value you specify is used to determine whether the time is a valid format. The valid values are:


The time format is required for function 1. For function D, it must be set to X'000000'. It is ignored for other functions.

Time separator. The separator used when accessing time result columns. The valid values are:


The time separator is required for function 1. For function D, it must be set to X'00'. It is ignored for other functions.

Use pointers. Whether the system pointers should be used to locate the main program and the SQL package instead of the symbolic names. The possible values follow:


The use pointers field is optional for all functions. The default value for the use pointers field is 0.

User-defined field. Up to 18 bytes of user-defined data that is inserted into the database performance monitor table. The data is only written to the table if you are collecting database performance monitor statistics by using the Start Database Monitor (STRDBMON) or the Start Performance Monitor (STRPFRMON) command. The user-defined field is optional for all functions. If this field is desired when you collect data, you should use it consistently for all functions.

Using clause for describe. The value to assign to each SQLNAME variable in the SQLDA. The possible values are:


These are explained more completely in the DB2 for i SQL reference topic collection. The using clause is required for functions 7 and 9. It is ignored for other functions.

DLYPRP (delay PREPARE) is an option on an SQL precompile operation that cannot be specified on the creation of a package (function 1). DLYPRP(*NO) is used as the default.

See the DB2 for i documentation for a full description of all the options.

WITH HOLD. Whether the WITH HOLD SQL option should be applied to the statement. The possible values follow:


The WITH HOLD field is optional for functions 2 and 9. The default for WITH HOLD is N. It is ignored for all other functions.


Diagnostic Information Data Format

The following shows the format of the data returned in the SQL diagnostic information receiver when a statement, condition, or connection information item data is requested. For detailed descriptions of the fields in the table, see Diagnostic Information Field Descriptions.

The following shows the format of the diagnostic information item data returned in the SQL diagnostic information receiver for each diagnostic information item. For detailed descriptions of the fields in the table, see Diagnostic Information Field Descriptions.


Diagnostic Information Field Descriptions

Bytes available. The number of bytes of data available to be returned. All available data is returned if enough space is provided.

Bytes returned. The number of bytes of data returned.

Diagnostic information item. Diagnostic information item data returned in the SQL diagnostic information receiver for each diagnostic information item. For detailed description of the format of the returned data, see Diagnostic Information Data Format.

Data returned. Data returned for the diagnostic item identified by the key. See the DB2 for i SQL reference topic collection for information about the possible data value for the diagnostic item.

Key of diagnostic information item. Key that identifies the returned diagnostic information item. For a list of key values for each diagnostic information item available for retrieval, see Key Values and Data Types of Statement Diagnostic Information Items, Key Values and Data Types of Condition Diagnostic Information Items, or Key Values and Data Types of Connection Diagnostic Information Items.

Length of data returned. Length of data returned for the item.

Length of diagnostic information item. Length of the information returned for the item. This length can be used to access the next diagnostic information item.

Number of diagnostic information items returned. Number of diagnostic information returned in the space provided.

Reserved. A field that can be ignored.

Type of data returned. Type of the data returned for the item. The possible values are:


Key Values and Data Types of Statement Diagnostic Information Items


Key Values and Data Types of Condition Diagnostic Information Items


Key Values and Data Types of Connection Diagnostic Information Items


Multiple Row Statement Using SQLDA Setup Requirements

Just as in the case of a multiple row FETCH, the support for multiple row INSERT and MERGE with an SQLDA expects the users to have two contiguous areas. One is for the data and the other is for the indicators. The former contains rows of data (the number of rows is given on function 3 calls), and the latter contains rows of indicators.

If none of the columns is null capable, there is no need to have an indicator area. If any of the columns is null capable, all the columns should be turned into null capable (that is, sqltype in all the sqlvar entries should be an odd number), and the row indicator area should have as many indicators per row as there are columns.

In the SQLDA, the pointer sqldata in all the sqlvar entries should be pointing at the data elements for the first row. Similarly, the pointer sqlind in all the sqlvar entries should be pointing at the indicators for the first row, except in the case where there are no null-capable columns at all.


Usage Notes

This function is not threadsafe when called in the following way:


Error Messages




API introduced: V2R3