SQLGetDescRec

It 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.

Syntax

SQLRETURN SQL_API SQLGetDescRec( SQLHDESC aDescriptorHandle,
SQLSMALLINT aRecordNumber,
SQLCHAR *aName,
SQLSMALLINT aBufferLength,
SQLSMALLINT *aStringLength,
SQLSMALLINT *aType,
SQLSMALLINT *aSubType,
SQLLEN *aLength,
SQLSMALLINT *aPrecision,
SQLSMALLINT *aScale,
SQLSMALLINT *aNullable )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDESC aDescriptorHandle Input Descriptor handle
SQLSMALLINT aRecordNumber Input Line number
SQLCHAR* aName Output A name in character string
SQLSMALLINT aBufferLength Input Buffer size of a name in character string
SQLSMALLINT* aStringLength Output Length of a name in character string
SQLSMALLINT* aType Output Type of column
SQLSMALLINT* aSubType Output Subtype of column
SQLLEN* aLength Output Length of column
SQLSMALLINT* aPrecision Output Accuracy of column
SQLSMALLINT* aScale Output Scale of column
SQLSMALLINT* aNullable Output NULL argument of column

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination/ Column number is out of range.
SQL_INVALID_HANDLE Abnormal termination/ Unallocated descriptor handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
07009 Invalid descriptor index Invalid column number

Sample Code

SQLCHAR Name[255];
SQLSMALLINT BufferLength = 255;
SQLSMALLINT StringLength;
SQLSMALLINT Type;
SQLSMALLINT SubType;
SQLLEN Length;
SQLSMALLINT Precision;
SQLSMALLINT Scale;
SQLSMALLINT Nullable;

SQLGetDescRec(gDesc, 0,
Name, BufferLength,
&StringLength, &Type,
&SubType, &Length,
&Precision, &Scale,
&Nullable);

SQLGetDiagField

It returns the current value of a filed of a record of the diagnostic data structure that contains error, warning, and status information.

Syntax

SQLRETURN SQL_API SQLGetDiagField( SQLSMALLINT aHandleType,
SQLHANDLE aHandle,
SQLSMALLINT aRecordNumber,
SQLSMALLINT aDiagIdentifier,
SQLPOINTER aDiagInfo,
SQLSMALLINT aBufferLength,
SQLSMALLINT *aStringLength )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLSMALLINT aHandleType Input Types of handle(SQL_HANDLE_ENV/ SQL_HANDLE_DBC/ SQL_HANDLE_STMT/ SQL_HANDLE_DESC)
SQLHANDLE aHandle Input Handles/*Handles for retrieving the diagnostic data
SQLSMALLINT aRecordNumber Input Line number
SQLSMALLINT aDiagIdentifier Input Type of diagnostic data/ *See the table of argument below for more information.
SQLPOINTER aDiagInfo Output Result value of diagnostic data
SQLSMALLINT aBufferLength Input Buffer size of the result value
SQLSMALLINT* aStringLength Output Length of the result value

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination/ *Invalid types of diagnostic data
SQL_INVALID_HANDLE Abnormal termination / *Unallocated handles
SQL_NO_DATA Abnormal termination/* No diagnostic data

Table of Arguments

Table. Table of Arguments

aDiagIdentifier argument Data type
SQL_DIAG_CURSOR_ROW_COUNT Integer
SQL_DIAG_ROW_COUNT Integer
SQL_DIAG_NUMBER Integer
SQL_DIAG_RETURNCODE Integer
SQL_DIAG_CLASS_ORIGIN String
SQL_DIAG_COLUMN_NUMBER Integer
SQL_DIAG_MESSAGE_TEXT String
SQL_DIAG_NATIVE Integer
SQL_DIAG_ROW_NUMBER Integer
SQL_DIAG_SQLSTATE String
SQL_DIAG_SUBCLASS_ORIGIN String

Sample Code

Refer to SQLAllocHandle for more information.

SQLGetDiagRec

It returns the current values of multiple fields of a diagnostic record that contains error, warning, and status information.

Syntax

SQLRETURN SQL_API SQLGetDiagRec( SQLSMALLINT aHandleType,
SQLHANDLE aHandle,
SQLSMALLINT aRecordNumber,
SQLCHAR * aState,
SQLINTEGER * aNativeError,
SQLCHAR * aMessageText,
SQLSMALLINT aBufferLength,
SQLSMALLINT * aStringLength )

Argument

Table. Argument

Type Name of Argument Input/Output Description
SQLSMALLINT aHandleType Input Handle type to get diagnostic codes. Must be one of the following:( SQL_HANDLE_ENV/ SQL_HANDLE_DBC/ SQL_HANDLE_STMT/ SQL_HANDLE_DESC)
SQLHANDLE aHandle Input A handle for the diagnostic data structure, of the type indicated by handletype.
SQLSMALLINT aRecordNumber Input Status records are numbered from 1.
SQLCHAR* aState Output Return a five-character SQLSTATE code for the diagnostic record.
SQLINTEGER* aNativeError Output Return the native error code.
SQLCHAR* aMessageText Output Return the diagnostic message text string.
SQLSMALLINT aBufferLength Input Length of the message text buffer in characters.
SQLSMALLINT* aStringLength Output Length of the error message.

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination/ Record number was negative or 0. Failed to retrieve the diagnostic data *Length of buffer was less than 0.
SQL_INVALID_HANDLE Annormal termination/ *Handle was not a valid handle.
SQL_NO_DATA Abnormal termination The record number was greater than the number of diagnostic records that existed for the handle specified in handle. Failed to retrieve the diagnostic record

Sample Code

Refer to SQLAllocHandle for more information.

SQLGetEnvAttr

It returns the current setting of an environment attribute.

Syntax

SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV aEnv,
SQLINTEGER aAttr,
SQLPOINTER aParam,
SQLINTEGER aParamMax,
SQLINTEGER* aParamLength )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHENV aEnv Input Environment handle
SQLINTEGER aAttr Input Selected Attribute value. The values can be set as follows: SQL_ATTR_ODBC_VERSION SQL_ATTR_OUTPUT_NTS
SQLPOINTER aValuePtr Output Pointer to result value
SQLINTEGER aValueMax Input Buffer length of result value. If value of result is not character string, it is ignored.
SQLINTEGER* aValueLength Output Length of the result value.The length of aValueMax is stored if it is less than the length of aValueMax.

Attribute Value

Table. Attribute Value

Attribute value Description Data type
SQL_ATTR_ODBC_VERSION To support ODBC version Integer
SQL_ATTR_OUTPUT_NTS To output whether to use NTS Integer

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_INVALID_HANDLE Abnormal termination *Environment handle is NULL.
SQL_SUCCESS_WITH_INFO Normal termination with information *Unsupported attribute handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
HYC00 Optional feature not implemented Input attribute was not supported by the driver.

Sample Code

SQLGetEnvAttr (gEnv, SQL_ATTR_CONNECTION_POOLING, (SQLPOINTER) &uIntVal,(SQLINTEGER) sizeof(uIntVal), NULL);

SQLGetFunctions

It returns information about whether a driver supports a specific ODBC function.

Syntax

SQLRETURN SQL_API SQLGetFunctions(SQLHDBC aCon, SQLUSMALLINT aFunctionId,SQLUSMALLINT *aSupportedPtr)

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDBC aCon Input Connection handle
SQLUSMALLINT aFunctionId Input Number of functions/ SQL_API_ODBC3_ALL_FUNCTIONS and SQL_API_ALL_FUNCTIONS are supported functions. Able to select a function as an argument of the function named SQL_API_FUNCTIONS.
SQLUSMALLINT* aSupportedPtr Output Pointer whether it is supported functions: A single record is returned if a specified function is supported. If it includes ALL_FUNCTIONS attribute, array is returned.

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination

Sample Code

SQLUSMALLINT fALLExists[100];
SQLGetFunctions(gDbc, SQL_API_ALL_FUNCTIONS, fALLExists);

SQLGetInfo

It returns general information about the driver and data source associated with a connection.

Syntax

SQLRETURN SQL_API SQLGetInfo( SQLHDBC aCon,
SQLUSMALLINT aInfoType,
SQLPOINTER aValuePtr,
SQLSMALLINT aValueSize,
SQLSMALLINT *aStrLenPtr )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHDBC aCon Input Connection handle
SQLUSMALLINT aInfoType Input Type of information
SQLPOINTER aValuePtr Output Pointer to results: *Buffer to return the information based on the information type requested.
SQLSMALLINT aValueSize Input Buffer size of the result value *Ignore if the result value is not a string.
SQLSMALLINT* aStrLenPtr Output The length of the result value/ *If the size of data is greater than the buffer size, apply the buffer size.

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination/ *Invalid information type
SQL_INVALID_HANDLE Abnormal termination/ *Invalid connection handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
HY096 Invalid information type Invalid information type

Sample Code

SQLGetInfo(hdbc, SQL_DATABASE_NAME, dbName, (SQLSMALLINT)BUFFERSIZE, (SQLSMALLINT *)&bufferLen);
printf("dbname : %s\n", dbName);

SQLGetStmtAttr

It returns the current setting of a statement attribute.

Syntax

SQLRETURN SQL_API SQLGetStmtAttr( SQLHSTMT aStmt,
SQLINTEGER aAttribute,
SQLPOINTER aValueStr,
SQLINTEGER aBufferLength,
SQLINTEGER *aStringLengthPtr )

Arguments

Table. Arguments

Type Name of Argument Input/Output Description
SQLHSTMT aStmt Input Statement handle
SQLINTEGER aAttribute Input Attribute handle
SQLPOINTER aValueStr Output Buffer pointer to result values.
SQLINTEGER aBufferLength Input Buffer size of result values./ *Not used
SQLINTEGER* aStringLengthPtr Output Data length of result values.

Return Values

Table. Return Values

Return Value Description
SQL_SUCCESS Normal termination
SQL_ERROR Abnormal termination Buffer pointer of result value is NULL. Not supported attribute type.
SQL_INVALID_HANDLE Abnormal termination/ *Invalid statement handle

Diagnostic Codes

Table. Diagnostic Codes

Code Error Description
HYC00 Optional feature not implemented Not supported attribute type

Sample Code

SQLGetStmtAttr(gStmt, SQL_ATTR_APP_PARAM_DESC, &hApd1, 0, NULL);

results matching ""

    No results matching ""