Version Introduced: ODBC 3.0 Standards Compliance: ISO 92
SQLGetDescRec returns the current settings or values of multiple fields of a descriptor record. The fields returned describe the name, data type, and storage of column or parameter data.
SQLRETURN SQLGetDescRec( SQLHDESC DescriptorHandle, SQLSMALLINT RecNumber, SQLCHAR * Name, SQLSMALLINT BufferLength, SQLSMALLINT * StringLengthPtr, SQLSMALLINT * TypePtr, SQLSMALLINT * SubTypePtr, SQLLEN * LengthPtr, SQLSMALLINT * PrecisionPtr, SQLSMALLINT * ScalePtr, SQLSMALLINT * NullablePtr);
[Input] Descriptor handle.
[Input] Indicates the descriptor record from which the application seeks information. Descriptor records are numbered from 1, 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 or equal to 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.)
[Output] A pointer to a buffer in which to return the SQL_DESC_NAME field for the descriptor record.
If Name is NULL, StringLengthPtr will still return the total number of characters (excluding the null-termination character for character data) available to return in the buffer pointed to by Name.
[Input] Length of the *Name buffer, in characters.
[Output] A pointer to a buffer in which to return the number of characters of data available to return in the *Name buffer, excluding the null-termination character. If the number of characters 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 the driver.
[Output] A pointer to a buffer in which to return the value of the SQL_DESC_TYPE field for the descriptor record.
[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.
[Output] A pointer to a buffer in which to return the value of the SQL_DESC_OCTET_LENGTH field for the descriptor record.
[Output] A pointer to a buffer in which to return the value of the SQL_DESC_PRECISION field for the descriptor record.
[Output] A pointer to a buffer in which to return the value of the SQL_DESC_SCALE field for the descriptor record.
[Output] A pointer to a buffer in which to return the value of the SQL_DESC_NULLABLE field for the descriptor record.
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, SQL_NO_DATA, or SQL_INVALID_HANDLE.
SQL_NO_DATA is returned if RecNumber is greater than the current number of descriptor records.
SQL_NO_DATA is returned if DescriptorHandle is an IRD handle and the statement is in the prepared or executed state but there was no open cursor associated with it.
When SQLGetDescRec returns SQL_ERROR or SQL_SUCCESS_WITH_INFO, an associated SQLSTATE value can be obtained by calling SQLGetDiagRec with a HandleType of SQL_HANDLE_DESC and a Handle of DescriptorHandle. The following table lists the SQLSTATE values typically returned by SQLGetDescRec and explains each one in the context of this function; the notation "(DM)" precedes the descriptions of SQLSTATEs returned by the Driver Manager. The return code associated with each SQLSTATE value is SQL_ERROR, unless noted otherwise.
Driver-specific informational message. (Function returns SQL_SUCCESS_WITH_INFO.)
String data, right truncated
The buffer *Name was not large enough to return the entire descriptor field. Therefore, the field was truncated. The length of the untruncated descriptor field is returned in *StringLengthPtr. (Function returns SQL_SUCCESS_WITH_INFO.)
Invalid descriptor index
The FieldIdentifier argument was a record field, the RecNumber argument was set to 0, and the DescriptorHandle argument was an IPD handle.
(DM) The RecNumber argument was set to 0, and the SQL_ATTR_USE_BOOKMARKS statement attribute was set to SQL_UB_OFF, and the DescriptorHandle argument was an IRD handle.
The RecNumber argument was less than 0.
Communication link failure
The communication link between the driver and the data source to which the driver was connected failed before the function completed processing.
An error occurred for which there was no specific SQLSTATE and for which no implementation-specific SQLSTATE was defined. The error message returned by SQLGetDiagRec in the *MessageText buffer describes the error and its cause.
Memory allocation error
The driver was unable to allocate the memory that is required to support execution or completion of the function.
Associated statement is not prepared
DescriptorHandle was associated with an IRD, and the associated statement handle was not in the prepared or executed state.
Function sequence error
(DM) 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.
(DM) DescriptorHandle was associated with a StatementHandle for which SQLExecute, SQLExecDirect, SQLBulkOperations, or SQLSetPos was called and returned SQL_NEED_DATA. This function was called before data was sent for all data-at-execution parameters or columns.
(DM) An asynchronously executing function was called for the connection handle that is associated with the DescriptorHandle. This asynchronous function was still executing when SQLGetDescRec was called.
Memory management error
The function call could not be processed because the underlying memory objects could not be accessed, possibly because of low memory conditions.
Connection is suspended due to unknown transaction state. Only disconnect and read-only functions are allowed.
(DM) For more information about suspended state, see SQLEndTran Function.
Connection timeout expired
The connection timeout period expired before the data source responded to the request. The connection timeout period is set through SQLSetConnectAttr, SQL_ATTR_CONNECTION_TIMEOUT.
Driver does not support this function
(DM) The driver associated with DescriptorHandle does not support the function.
An application can call SQLGetDescRec to retrieve the values of the following descriptor fields for a single column or parameter:
SQL_DESC_DATETIME_INTERVAL_CODE (for records whose type is SQL_DATETIME or SQL_INTERVAL)
SQLGetDescRec does not retrieve the values for header fields.
An application can prevent the return of a field's setting by setting the argument that corresponds 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 that has no default value and has not been set yet, the function returns SQL_SUCCESS but the value returned for the field is undefined. For more information, see "Initialization of Descriptor Fields" in SQLSetDescField.
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. For more information about descriptors, see Descriptors.