SQLSetDescRec

 

System_CAPS_ICON_warning.jpg Warning

SQL Server Native Client (SNAC) is not supported beyond SQL Server 2012. Avoid using SNAC in new development work, and plan to modify applications that currently use it. The Microsoft ODBC Driver for SQL Server provides native connectivity from Windows to Microsoft SQL Server and Microsoft Azure SQL Database.

This topic discusses SQLSetDescRec functionality that is specific to SQL Server Native Client.

SQLSetDescRec can be used to set descriptor fields for table-valued parameters and table-valued parameter columns. Table-valued parameter columns are only available when the descriptor header field SQL_SOPT_SS_PARAM_FOCUS is set to the ordinal of a record that has SQL_DESC_TYPE set to SQL_SS_TABLE. For more information about SQL_SOPT_SS_PARAM_FOCUS, see SQLSetStmtAttr.

The following table describes the mapping between parameters and descriptor fields.

ParameterRelated attribute for non–table-valued parameter types, including table-valued parameter columnsRelated attribute for table-valued parameters
TypeSQL_DESC_TYPESQL_SS_TABLE
SubTypeIgnoredFor records of type SQL_DATETIME or SQL_INTERVAL, set this to SQL_DESC_DATETIME_INTERVAL_CODE.
LengthSQL_DESC_OCTET_LENGTHThe length of the table-valued parameter type name. This can be SQL_NTS if the type name is null terminated, or zero if the table-valued parameter type name is not required.
PrecisionSQL_DESC_PRECISIONSQL_DESC_ARRAY_SIZE
ScaleSQL_DESC_SCALEUnused. This parameter should be zero.
DataPtrSQL_DESC_DATA_PTR in APDSQL_CA_SS_TYPE_NAME

This parameter is optional for stored procedure calls, and NULL can be specified if it is not required. This parameter must be specified for SQL statements that are not procedure calls.

 DataPtr also serves as a unique value that the application can use to identify this table-valued parameter when variable row binding is used.
StringLengthPtrSQL_DESC_OCTET_LENGTH_PTRSQL_DESC_OCTET_LENGTH_PTR

For a table-valued parameter, this is the number of rows to transfer or SQL_DATA_AT_EXEC. This is a pointer to a value that holds the number of rows to transfer with SQLExecDirect.
IndicatorPtrSQL_DESC_INDICATOR_PTRSQL_DESC_INDICATOR_PTR

For more information about table-valued parameters, see Table-Valued Parameters (ODBC).

The values allowed for date/time types are as follows:

TypeSubTypeLengthPrecisionScale
datetimeSQL_DATETIMESQL_CODE_TIMESTAMP433
smalldatetimeSQL_SQL_DATETIMESQL_CODE_TIMESTAMP800
dateSQL_DATETIMESQL_CODE_DATE600
timeSQL_SS_TIME20100..70..7
datetime2SQL_DATETIMESQL_CODE_TIMESTAMP160..70..7
datetimeoffsetSQL_SS_TIMESTAMPOFFSET0200..70..7

For more information, see Date and Time Improvements (ODBC).

SQLSetDescRec supports large CLR user-defined types (UDTs). For more information, see Large CLR User-Defined Types (ODBC).

SQLSetDescRec
ODBC API Implementation Details

Community Additions

ADD
Show: