SQLSetEnvAttr - Set environment attribute
SQLSetEnvAttr() sets an environment attribute for the current environment.
Syntax
An environment attribute cannot be set if a connection handle has been allocated. In order for the attribute to apply to the entire CLI environment, the environment attributes must be in place before this initial connection is made. An HY010 error code is returned otherwise.
SQLRETURN SQLSetEnvAttr (SQLHENV henv,
SQLINTEGER Attribute,
SQLPOINTER Value,
SQLINTEGER StringLength);
Function arguments
Data type | Argument | Use | Description |
---|---|---|---|
SQLHEN | henv | Input | Environment handle. |
SQLINTEGER | Attribute | Input | Environment attribute to set. Refer to Table 2 for more information. |
SQLPOINTER | Value | Input | Appropriate value for Attribute. |
SQLINTEGER | StringLength | Input | Length of Value in bytes if the attribute value is a character string; if Attribute does not denote a string, then DB2® for i CLI ignores StringLength. |
Usage
In environments where the current application may exist in the same job as other applications using CLI, connections attributes should be used instead of environment attributes. Otherwise, setting environment attributes may cause the other application to behave unexpectedly. Ideally, the only environment attributes that should be used are SQL_ATTR_ENVHNDL_COUNTER and SQL_ATTR_SERVER_MODE.
Attribute | Contents |
---|---|
SQL_ATTR_DATE_FMT | A 32-bit integer value:
|
SQL_ATTR_DATE_SEP | A 32-bit integer value:
Separators only apply to the following SQL_ATTR_DATE_FMT attribute types:
|
SQL_ATTR_DECIMAL_SEP | A 32-bit integer value:
|
SQL_ATTR_DEFAULT_LIB | A character value that indicates the default library that is used for resolving unqualified file references. |
SQL_ATTR_ENVHNDL_COUNTER | A 32-bit integer value:
|
SQL_ATTR_ESCAPE_CHAR | A
character value that indicates
the escape character to be used when specifying a search pattern in
either SQLColumns( ) or SQLTables( ). SQL_ATTR_ESCAPE_CHAR is only honored if the connection attribute SQL_ATTR_OLD_MTADTA_BEHAVIOR is set to SQL_TRUE. |
SQL_ATTR_FOR_FETCH_ONLY | A 32-bit integer value:
The attribute SQL_ATTR_FOR_FETCH_ONLY can also be set for individual statements using SQLSetStmtAttr(). |
SQL_ATTR_INCLUDE_NULL_IN_LEN | A 32-bit integer value:
|
SQL_ATTR_JOB_SORT_SEQUENCE | A 32-bit integer value:
|
SQL_ATTR_NON_HEXCCSID | A 32-bit integer value:
|
SQL_ATTR_OUTPUT_NTS | A 32-bit integer value:
The CLI functions affected by this attribute are all functions called for the environment (and for any connections allocated under the environment) that have character string parameters. |
SQL_ATTR_REQUIRE_PROFILE | A 32-bit integer value:
|
SQL_ATTR_SERVER_MODE | A 32-bit integer value:
|
SQL_ATTR_SYS_NAMING | A 32-bit integer value:
|
SQL_ATTR_TIME_FMT | A 32-bit integer value:
|
SQL_ATTR_TIME_SEP | A 32-bit integer value:
|
SQL_ATTR_TRUNCATION_RTNC | A 32-bit integer value:
|
SQL_ATTR_UTF8 | A
32-bit integer value:
|
Return codes
- SQL_SUCCESS
- SQL_SUCCESS_WITH_INFO
- SQL_ERROR
- SQL_INVALID_HANDLE
Diagnostics
SQLSTATE | Description | Explanation |
---|---|---|
HY009 | Parameter value that is not valid | The specified Attribute is
not supported by DB2 for
i CLI.
Given specified Attributevalue, the value specified for the argument Value is not supported. The argument pValue is a null pointer. |
HY010 | Function sequence error | Connection handles are already allocated. |