This new feature uses an environment variable to externally configure the DB-Library version level at runtime to change the application code by calling dbsetversion. It provides the following:
Retrieves the environment variable at the DB-Library initialization stage
Stores the environment variable value as the version level
Currently, in the source code, DB-Library sets the default version level to DBVERSION_46. The only way you can change this default version level is to call dbsetversion in an application. If a user wishes to use features provided by TDS protocol version 5.0 (for example, numeric and decimal types), the hard coded default version level (DBVERSION_46) needs to be changed. In the past, users had to add the call dbsetversion(DBVERSION_100) to their code. This feature allows you to decide the DB-Library version level without calling dbsetversion from an application.
The following are definitions used in describing the new DB-Library configuration variable:
DB-Library — a collection of C programming API routines and macros that allow an application to interact with data server and Open Server applications.
CT-Library — a collection of C programming API routines used in writing client applications.
Version level — a parameter in DB-Library that is used to specify the version of the TDS protocol. There are three valid values:
DBVERSION_46 — DB-Library is running with TDS version 4.6 protocol.
DBVERSION_100 — DB-Library is running with TDS version 5.0 protocol
DBVERSION_UNKNOWN —the version level has not been decided yet.
dbsetversion — a DB-Library API that sets the version level of the DB-Library in the client’s application.
dbinit — an API that initializes the DB-Library. It must be called before calling any other DB-Library routines.
To implement this feature, you must define a new environment variable SYBOCS_DBVERSION to allow the DB-Library version level to be configured externally.
The following are valid values for this environment variable:
DBVERSION_46
DBVERSION_100
Any other value causes the DB-Library application to fail.
The following paragraphs describe the order for processing the environment variable and the dbsetversion in a DB-Library application:
If an environment variable is not defined and the dbsetversion is not called in an application, the version level is DBVERSION_46, which is currently the default version in the DB_Library source code.
If an environment variable is not defined and the dbsetversion is called with a value of DBVERSION_100 or DBVERSION_46, the version level is DBVERSION_100 or DBVERSION_46, respectively.
If an environment variable is defined as DBVERSION_100 or DBVERSION_46 and the dbsetversion is not called in an application, the version level is DBVERSION_100 or DBVERSION_46, respectively.
If an environment variable is defined as DBVERSION_100 and dbsetversion is called to set version level as DBVERSION_46 in the application, the version level is DBVERSION_46, since the dbsetversion overrides the environment variable and decides the final version level.