Call Level Interface Guide and Reference

SQLGetDescRec - Get Multiple Field Settings of Descriptor Record

Purpose


Specification: DB2 CLI 5.0 ODBC 3.0 ISO CLI

SQLGetDescRec() returns the current settings of multiple fields of a descriptor record. The fields returned describe the name, data type, and storage of column or parameter data.

Syntax

SQLRETURN   SQLGetDescRec    (SQLHDESC          DescriptorHandle,
                              SQLSMALLINT       RecNumber,
                              SQLCHAR           *Name,
                              SQLSMALLINT       BufferLength,
                              SQLSMALLINT       *StringLengthPtr,
                              SQLSMALLINT       *TypePtr,
                              SQLSMALLINT       *SubTypePtr,
                              SQLINTEGER        *LengthPtr,
                              SQLSMALLINT       *PrecisionPtr,
                              SQLSMALLINT       *ScalePtr,
                              SQLSMALLINT       *NullablePtr);

Function Arguments

Table 100. SQLGetDescRec Arguments
Data Type Argument Use Description
SQLHDESC DescriptorHandle input Descriptor handle.
SQLSMALLINT RecNumber input Indicates the descriptor record from which the application seeks information. Descriptor records are numbered from 0, with record number 0 being the bookmark record. The RecNumber argument must be less than or equal to the value of SQL_DESC_COUNT. If RecNumber is less than SQL_DESC_COUNT, but the row does not contain data for a column or parameter, a call to SQLGetDescRec() will return the default values of the fields (for more information, see "Initialization of Descriptor Fields" in SQLSetDescField()).
SQLCHAR Name output A pointer to a buffer in which to return the SQL_DESC_NAME field for the descriptor record.
SQLINTEGER BufferLength input Length of the *Name buffer, in bytes.
SQLSMALLINT *StringLengthPtr output A pointer to a buffer in which to return the number of bytes of data available to return in the *Name buffer, excluding the null termination character. If the number of bytes was greater than or equal to BufferLength, the data in *Name is truncated to BufferLength minus the length of a null termination character, and is null terminated by DB2 CLI.
SQLSMALLINT TypePtr output A pointer to a buffer in which to return the value of the SQL_DESC_TYPE field for the descriptor record.
SQLSMALLINT SubTypePtr output For records whose type is SQL_DATETIME or SQL_INTERVAL, this is a pointer to a buffer in which to return the value of the SQL_DESC_DATETIME_INTERVAL_CODE field.
SQLINTEGER LengthPtr output A pointer to a buffer in which to return the value of the SQL_DESC_OCTET_LENGTH field for the descriptor record.
SQLSMALLINT PrecisionPtr output A pointer to a buffer in which to return the value of the SQL_DESC_PRECISION field for the descriptor record.
SQLSMALLINT ScalePtr output A pointer to a buffer in which to return the value of the SQL_DESC_SCALE field for the descriptor record.
SQLSMALLINT *NullablePtr output A pointer to a buffer in which to return the value of the SQL_DESC_NULLABLE field for the descriptor record.

Usage

An application can call SQLGetDescRec() to retrieve the values of the following fields for a single column or parameter:

SQLGetDescRec() does not retrieve the values for header fields.

An application can inhibit the return of a field's setting by setting the argument corresponding to the field to a null pointer. When an application calls SQLGetDescRec() to retrieve the value of a field that is undefined for a particular descriptor type, the function returns SQL_SUCCESS but the value returned for the field is undefined. For example, calling SQLGetDescRec() for the SQL_DESC_NAME or SQL_DESC_NULLABLE field of an APD or ARD will return SQL_SUCCESS but an undefined value for the field.

When an application calls SQLGetDescRec() to retrieve the value of a field that is defined for a particular descriptor type, but has no default value and has not been set yet, the function returns SQL_SUCCESS but the value returned for the field is undefined.

The values of fields can also be retrieved individually by a call to SQLGetDescField(). For a description of the fields in a descriptor header or record, see SQLSetDescField - Set a Single Field of a Descriptor Record. For more information on descriptors, see Using Descriptors.

Return Codes

SQL_NO_DATA is returned if RecNumber is greater than the number of descriptor records.

SQL_NO_DATA is returned if DescriptorHandle is an IRD handle and the statement in in the prepared or executed state, but there was no open cursor associated with it.

Diagnostics

Table 101. SQLGetDescRec SQLSTATEs
SQLSTATE Description Explanation
01000 Warning. Informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
01004 Data truncated. The buffer *Name was not large enough to return the entire descriptor field, so the field was truncated. The length of the untruncated descriptor field is returned in *StringLengthPtr. (Function returns SQL_SUCCESS_WITH_INFO.)
07009 Invalid descriptor index. The RecNumber argument was set to 0 and the DescriptorHandle argument was an IPD handle.

The RecNumber argument was set to 0, and the SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF.

The RecNumber argument was less than 0.

08S01 Communication link failure. The communication link between DB2 CLI and the data source to which it was connected failed before the function completed processing.
HY000 General error. An error occurred for which there was no specific SQLSTATE. The error message returned by SQLGetDiagRec() in the *MessageText buffer describes the error and its cause.
HY001 Memory allocation failure. DB2 CLI was unable to allocate the memory required to support execution or completion of the function.
HY007 Associated statement is not prepared. DescriptorHandle was associated with an IRD, and the associated statement handle was not in the prepared or executed state.
HY010 Function sequence error. DescriptorHandle was associated with a StatementHandle for which an asynchronously executing function (not this one) was called and was still executing when this function was called.

DescriptorHandle was associated with a StatementHandle for which SQLExecute() or SQLExecDirect() was called and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns.

HY013 Unexpected memory handling error. DB2 CLI was unable to access memory required to support execution or completion of the function.

Restrictions

None.

Example

See the README file in the sqllib\samples\cli (or sqllib/samples/cli) subdirectory for a list of appropriate samples.

References


[ Top of Page | Previous Page | Next Page ]