Session variables in connection and sign-on routines
Db2 supplies default session variables and the connection exit routine and the sign-on exit routine support up to 10 more session variables.
You can define the additional session variables and use them to provide information to applications by using the GETVARIABLE function. For more information, see GETVARIABLE scalar function
The session variable structure
The connection exit routine and the sign-on exit routine point to the session variable structure (DSNDSVS). DSNDSVS specifies the maximum number of entries in the session array, the actual number of entries in the session array, and a pointer to the session variable array. The default value for the actual number of session variables is zero.
Defining session variables
To define session variables, use the session variable array (DSNDSVA) to list up to 10 session variables as name and value pairs. The session variables that you establish in the connection exit routine and the sign-on exit routine are defined in the SESSION schema. The values that the exit routine supplies in the session variable array replace the previous values.
Example
For example, the following session variable array lists six session variables.
Name | Value |
---|---|
default_database | DATAXM |
default_driver | PZN4Y7 |
location | Kyoto |
member_of | GROUP_42 |
filename | report.txt |
account_number | A1-X142783 |
The unqualified names are defined as VARCHAR(128), and the values are defined as VARCHAR(255). The exit routines must provide these values in Unicode CCSID 1208.