GETVARIABLE
The GETVARIABLE function returns a varying-length character-string representation of the current value of the session variable that is identified by the argument.
>>-GETVARIABLE(string-constant-+------------------------------------+-)->< +-,--default-value-------------------+ '-,--CAST--(--NULL AS -VARCHAR(1)--)-'
The schema is SYSIBM.
- string-constant
- Specifies a string constant that contains the name of the session
variable whose value is to be returned. The string constant:
- Must have a length that does not exceed 142 bytes.
- Must contain the fully qualified name of the variable, with no embedded blanks. Delimited identifiers must not be specified.
- Must not contain lowercase letters or characters that cannot be specified in an ordinary identifier.
The schema qualifier for the variable must be:
- SYSIBM for built-in session variables. For a list of the built-in session variables, see Built-in session variables.
- SESSION for user-defined session variables. User-defined session variables are established via the connection or signon exit routines.
- default-value
- Specifies a string constant that contains the value to be returned
if the specified variable does not exist or is not supported by DB2. default-value must
be a string constant that does not exceed 255 bytes.
If default-value is not specified and the specified user-defined session variable does not exist or the built-in session variable is not supported by DB2, an error is returned.
- CAST(NULL AS VARCHAR(1))
- Specifies that a null value is to be returned if the specified variable does not exist or is not supported by DB2.
The data type of the result is VARCHAR(255). The result can be null.
The CCSID of the result is the CCSID for Unicode mixed data.
SET :hv1 = GETVARIABLE('SYSIBM.PLAN_NAME');
SET :hv1 = GETVARIABLE('SYSIBM.XYZ');
SET :hv2 = GETVARIABLE('SESSION.TEST','TEST FAILED');
SET :hv3 = GETVARIABLE('SYSIBM.SYSTEM_EBCDIC_CCSID');
Regardless of the setting of the field MIXED DATA on the installation panel (YES or NO), the function returns three comma-delimited values that correspond to the SBCS, MIXED, and GRAPHIC CCSIDs for the encoding scheme.