Special registers in SQL statements
You can specify certain special registers in SQL statements. A special register, for example, CURRENT DATE, contains information that can be referenced in SQL statements.
For locally run SQL statements, the special registers and their contents are shown in the following table.
Special registers | Contents |
---|---|
CURRENT CLIENT_ACCTNG |
The accounting string for the client connection. |
CURRENT CLIENT_APPLNAME |
The application name for the client connection. |
CURRENT CLIENT_PROGRAMID |
The program ID for the client connection. |
CURRENT CLIENT_USERID |
The client user ID for the client connection. |
CURRENT CLIENT_WRKSTNNAME |
The workstation name for the client connection. |
CURRENT DATE |
The current date. |
CURRENT DEBUG MODE |
The debug mode to be used when creating or altering routines. |
CURRENT DECFLOAT ROUNDING MODE |
The rounding mode to be used when working with decimal floating point values. |
CURRENT DEGREE |
The number of tasks the database manager should run in parallel. |
CURRENT IMPLICIT XMLPARSE OPTION |
The whitespace handling options to be used for XML data when implicitly parsed without validation. |
CURRENT PATH |
The SQL path used to resolve unqualified data type names, procedure names, and function names in dynamically prepared SQL statements. |
CURRENT SCHEMA |
The schema name used to qualify unqualified database object references where applicable in dynamically prepared SQL statements. |
CURRENT SERVER |
The name of the relational database currently being used. |
CURRENT TIME |
The current time. |
CURRENT TIMESTAMP |
The current date and time in timestamp format. |
CURRENT TIMEZONE |
A duration of time that links local
time to Universal Time Coordinated (UTC) using the formula:
It is taken from the system value
QUTCOFFSET. |
SESSION_USER |
The runtime authorization identifier (user profile) of the job. |
SYSTEM_USER |
The authorization identifier (user profile) of the user connected to the database. |
If a single statement contains more than one reference to any of CURRENT DATE, CURRENT TIME, or CURRENT TIMESTAMP special registers, or the CURDATE, CURTIME, or NOW scalar functions, all values are based on a single clock reading.
For remotely run SQL statements, the values for special registers are determined at the remote system.
When a query over a distributed table references a special register, the contents of the special register on the system that requests the query are used. For more information about distributed tables, see the DB2® Multisystem topic collection.