Skip to content

SQLGetConnectAttr

SQLGetConnectAttr#

SQLGetConnectAttr gets the current setting of connection.

SQLGetConnectAttrW() as a Unicode string supports same execution as SQLGetConnectAttr().

Syntax#

SQLRETURN SQLGetConnectAttr (
       SQLHDBC          dbc,
       SQLINTEGER       Attribute,
       SQLPOINTER       ValuePtr,
       SQLINTEGER       BufferLength,
       SQLINTEGER       *StringLengthPtr ); 

Arguments#

Data Type Argument In/Output Description
SQLHDBC dbc Input Connection handle
SQLINTEGER Attribute Input Attribute to retrieve
SQLPOINTER ValuePtr Output Memory pointer to bring the value corresponding to the attribute
SQLINTEGER BufferLength Input - If ValuePtr is the pointer of character string, this has the byte length of string or the value of SQL_NTS.
- If
ValuePtr is the pointer of binary buffer, its value is the binary length of data.
- If *ValuePtr is the pointer with fixedlength data type like integer, its value is ignored.
SQLINTEGER StringLengthPtr Output This returns bytes (excluding the nulltermination characater) available to return in *ValuePtr.

Return Values#

SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR

Description#

In case the attribute returns the string, ValuePtr will be a pointer indicating the string buffer.

The maximum length of the returned string including the NULL-terminatior will be the BufferLength bytes.

Depending on the attribute, an application must establish connections before calling SQLGetConnectAttr().

List of Connection Attributes#

Attribute Contents
SQL_ATTR_AUTOCOMMIT 32-bit value to set reflection for the connection.
- SQL_AUTOCOMMIT_ON: Each SQL statement is automatically committed.
- SQL_AUTOCOMMIT_OFF: Not automatically committed.
SQL_ATTR_CONNECTION_TIMEOUT Set timeout value to prevent blocking that may occur in select() or poll() in an unstable network
SQL_ATTR_PORT Server port number (32-bit Integer)
SQL_ATTR_TXN_ISOLATION 32-bit value that sets the transaction isolation level for the current connection referred to by dbc.
SQL_ATTR_LOGIN_TIMEOUT SQLINTEGER value corresponding to the waiting time (in seconds) for logging in before the data is returned to an application.
The default depends on the driver.
If ValuePtr is 0, timeout will be disabled and connection attempt will be permanently awaited.
SQL_ATTR_CONNECTION_DEAD - SQL_CD_TRUE Disconnected status
SQL_CD_FALSE: Connected status
ALTIBASE_SOCK_RCVBUF_BLOCK_RATIO 32K unit rate of memory size set by socket receive buffer

Diagnosis#

SQLSTATE Description Comments
08S01 Communication channel error Communication channel failure before the function processing is completed between the Altibase CLI driver and the database
HYC00 Optional feature not implemented. Not supported by the driver specified in the argument Attribute.
SQLSetConnectAttr

Example#

< Refer to: $ALTIBASE_HOME/sample/SQLCLI/demo_dead.cpp >

rc = SQLGetConnectAttr( dbc, SQL_ATTR_CONNECTION_DEAD, &isDead, 0, NULL );
…

if ( rc == SQL_SUCCESS )
    {
        if ( isDead == SQL_CD_TRUE )
        {
            printf("The Connection has been lost.\n");
        }
        else
        {
            printf("The Connection is active.\n");
        } 
    }