Notify the client of an environment change.
CS_RETCODE srv_envchange(spp, type, oldvalp oldvallen, newvalp, newvallen)
SRV_PROC *spp; CS_INT type; CS_CHAR *oldvalp; CS_INT oldvallen CS_CHAR *newvalp; CS_INT newvallen
A pointer to an internal thread control structure.
The environment being changed. Currently, the only legal values are SRV_ENVDATABASE and SRV_ENVLANG, the name of the current database and the current national language, respectively.
A pointer to the character string containing the old value. It can be NULL. Its length in bytes is stored in oldvallen.
The length, in bytes, of the string in *oldvalp. It can be CS_NULLTERM, which indicates that the string in *oldvalp is null terminated. It can also be CS_UNUSED, indicating that the string in *oldvalp is NULL.
A pointer to the character string containing the new value of the environment variable. It can be null. Its length in bytes is stored in newvallen.
The length, in bytes, of the string in *newvalp. It can be CS_NULLTERM, which indicates that the string in newvalp is null terminated. It can also be CS_UNUSED, indicating that the string in *newvalp is NULL.
Returns |
To indicate |
---|---|
CS_SUCCEED |
The routine completed successfully. |
CS_FAIL |
The routine failed. |
#include <ospublic.h>
/*
** Local Prototype.
*/
CS_RETCODE ex_srv_envchange PROTOTYPE((
SRV_PROC *spp
));
/*
** EX_SRV_ENVCHANGE
**
** Example routine to notify the client of an environment
** change.
**
** Arguments:
** spp A pointer to an internal thread control structure.
**
** Returns:
** CS_SUCCEED Succesfully notified client of environment
** change.
** CS_FAIL An error was detected.
**
*/
CS_RETCODE ex_srv_envchange(spp)
SRV_PROC *spp;
{
CS_RETCODE retval;
/*
** Notify the client that we’ve changed the database
** from “master” to “pubs2”.
*/
retval = srv_envchange(spp, SRV_ENVDATABASE, “master”,
CS_NULLTERM, “pubs2”, CS_NULLTERM);
return (retval);
}
There are various environment variables which can be set. Open Server handles some automatically, while others must be handled by an Open Server application. Currently, an application can only inform a client of a change to the current database or national language.
Open Server calls an Open Server application’s error handler any time one of the values changes. An Open Server application can change it through srv_envchange, or Open Server can change it using internal code, or both. The error number passed to the error handler is the Adaptive Server Enterprise message number sent back to a client when one of these values changes. This allows a client application to match the same message number to a changing value, whether the client is connected to an Open Server or an Adaptive Server Enterprise. Table 3-45 lists the message number and oserror.h #define that correspond to each changing value.
Changing value |
Message number |
#define in oserror.h |
---|---|---|
Current Database |
5701 |
SQLSRV_ENVDB |
National Language |
5703 |
SQLSRV_ENVLANG |