Enable delimited identifiers in ODBC

By default delimited identifiers are disabled when connecting through ODBC.

There are three ways to enable them, listed here in order of decreasing precedence:

The DELIMIDENT connection string keyword

If you are using a connection string to connect you can set the DELIMIDENT keyword to enable or disable delimited identifiers. If the keyword is set to y then delimited identifiers are enabled for the connection. If the keywords are set to n delimited identifiers are disabled for the connection. If the keyword is present but is set to no value it has no effect on whether delimited identifiers are enabled.

For example, this connection string connects by using a data source name (DSN) of mydsn and enables delimited identifiers for the connection.
"DSN=mydsn;DELIMIDENT=y;"
This connection string also connects by using the DSN mydsn but has no effect on whether delimited identifiers are used.
"DSN=mydsn;DELIMIDENT=;"

Setting the DELIMIDENT keyword in the connection string overrides any connection attributes or environment variables that enable or disable delimited identifiers.

The SQL_INFX_ATTR_DELIMIDENT connection attribute

You can enable or disable delimited identifiers for a given connection by setting the SQL_INFX_ATTR_DELIMIDENT connection attribute before connecting. The SQL_INFX_ATTR_DELIMIDENT connection attribute accepts the values listed in the following table.
Table 1. Allowed values for the SQL_INFX_ATTR_DELIMIDENT connection attribute
Value Effect
SQL_TRUE Delimited identifiers are enabled for the connection.
SQL_FALSE Delimited identifiers are disabled for the connection.
SQL_IFX_CLEAR Clears any previous settings so that this connection attribute has no effect on whether delimited identifiers are used.
For example, this call causes delimited identifiers to be enabled when the connection is made:
SQLSetConnectAttr(hdbc, SQL_INFX_ATTR_DELIMIDENT, SQL_TRUE, SQL_IS_INTEGER);

If this connection attribute is set to SQL_TRUE or SQL_FALSE the setting overrides the DELIMIDENT environment variable but not the DELIMIDENT connection string keyword.

The DELIMIDENT environment variable

In some HCL OneDB™ APIs, such as ESQL/C, delimited identifiers are enabled by setting the DELIMIDENT environment variable to any value. In ODBC, however, delimited identifiers are enabled by setting the DELIMIDENT environment variable to y and are disabled by setting it to n.