A special register is a storage area that is defined for an application process by the database manager and is used to store information that can be referenced in SQL statements. A reference to a special register is a reference to a value provided by the current server. If the value is a string, its CCSID is a default CCSID of the current server. The special registers can be referenced as follows:
>>-+-+-CURRENT DATE------+------+------------------------------>< | | (1) | | | '-CURRENT_DATE------' | +---CURRENT DEBUG MODE-------+ +---CURRENT DEGREE-----------+ +-+-CURRENT PATH----------+--+ | +-CURRENT FUNCTION PATH-+ | | | (1) | | | '-CURRENT_PATH----------' | +-+-CURRENT SCHEMA-+---------+ | '-CURRENT_SCHEMA-' | +-+-CURRENT SERVER-+---------+ | '-CURRENT_SERVER-' | +-+-CURRENT TIME------+------+ | | (1) | | | '-CURRENT_TIME------' | +-+-CURRENT TIMESTAMP------+-+ | | (1) | | | '-CURRENT_TIMESTAMP------' | +-+-CURRENT TIMEZONE-+-------+ | '-CURRENT_TIMEZONE-' | +-+-SESSION_USER-+-----------+ | '-USER---------' | '---SYSTEM_USER--------------'
The CURRENT DATE special register specifies a date that is based on a reading of the time-of-day clock when the SQL statement is executed at the current server. If this special register is used more than once within a single SQL statement, or used with CURRENT TIME, CURRENT TIMESTAMP, or the CURDATE, CURTIME, or NOW scalar functions within a single statement; all values are based on a single clock reading.26
Using the PROJECT table, set the project end date (PRENDATE) of the MA2111 project (PROJNO) to the current date.
UPDATE PROJECT SET PRENDATE = CURRENT DATE WHERE PROJNO = 'MA2111'
The CURRENT DEBUG MODE special register specifies whether SQL or Java procedures should be created or altered so they can be debugged by the Unified Debugger. Any explicit specification of the DEBUG MODE or the DBGVIEW option in the SET OPTION statement on the CREATE PROCEDURE or ALTER PROCEDURE statement overrides the value in the CURRENT DEBUG MODE special register. CURRENT DEBUG MODE affects static and dynamic SQL statements. The data type of the register is VARCHAR(8). The valid values include:
The value can be changed by invoking the SET CURRENT DEBUG MODE statement. For details about this statement, see SET CURRENT DEBUG MODE.
The initial value of CURRENT DEBUG MODE is DISALLOW.
The following statement prevents subsequent creates or alters of SQL or Java procedures from being debuggable:
SET CURRENT DEBUG MODE = DISALLOW
The CURRENT DEGREE special register specifies the degree of I/O or Symmetric MultiProcessing (SMP) parallelism for the execution of queries, index creates, index rebuilds, index maintenance, and reorganizes. CURRENT DEGREE affects static and dynamic SQL statements. The data type of the register is CHAR(5). The valid values include:
Use of parallel processing and the number of tasks used is determined based on the number of processors available in the system, this job's share of the amount of active memory available in the pool in which the job is run, and whether the expected elapsed time for the operation is limited by CPU processing or I/O resources. The database manager chooses an implementation that minimizes elapsed time based on the job's share of the memory in the pool.
The value can be changed by invoking the SET CURRENT DEGREE statement. For details about this statement, see SET CURRENT DEGREE.
The initial value of CURRENT DEGREE is determined by the current degree in effect from the CHGQRYA CL command, PARALLEL_DEGREE parameter in the current query options file (QAQQINI), or the QQRYDEGREE system value.
The following statement inhibits parallelism:
SET CURRENT DEGREE = '1'
The CURRENT PATH special register specifies the SQL path used to resolve unqualified distinct type names, function names, and procedure names in dynamically prepared SQL statements. It is also used to resolve unqualified procedure names that are specified as variables in SQL CALL statements (CALL variable). The data type is VARCHAR(3483).
The CURRENT PATH special register contains the value of the SQL path which is a list of one or more schema names, where each schema name is enclosed in delimiters and separated from the following schema by a comma. The delimiters and commas are included in the length of the special register. The maximum number of schema names in the path is 268.
For information on when the SQL path is used to resolve unqualified names in both dynamic and static SQL statements and the effect of its value, see Unqualified function, procedure, specific, and distinct type names.
The initial value of the CURRENT PATH special register in an activation group is established by the first SQL statement that is executed.
The value of the special register can be changed by executing the SET PATH statement. For details about this statement, see SET PATH. For portability across the platforms, it is recommended that a SET PATH statement be issued at the beginning of an application.
Set the special register so that schema SMITH is searched before schemas QSYS and QSYS2 (SYSTEM PATH).
SET CURRENT PATH SMITH, SYSTEM PATH
The CURRENT SCHEMA special register specifies a VARCHAR(128) value that identifies the schema name used to qualify unqualified database object references where applicable in dynamically prepared SQL statements.27 CURRENT SCHEMA is not used to qualify names in programs where the DYNDFTCOL has been specified. If DYNDFTCOL is specified in a program, its schema name is used instead of the CURRENT SCHEMA schema name.
The initial value of CURRENT SCHEMA is the authorization ID of the current session user.
The DFTRDBCOL keyword controls the schema name used to qualify unqualified database object references where applicable for static SQL statements.
Set the schema for object qualification to 'D123'.
SET CURRENT SCHEMA = 'D123'
The CURRENT SERVER special register specifies a VARCHAR(18) value that identifies the current application server.
CURRENT SERVER can be changed by the CONNECT (Type 1), CONNECT (Type 2), or SET CONNECTION statements, but only under certain conditions. See the description in CONNECT (Type 1), CONNECT (Type 2), and SET CONNECTION.
CURRENT SERVER cannot be specified unless the local relational database is named by adding the entry to the relational database directory using the ADDRDBDIRE or WRKRDBDIRE command.
Set the host variable APPL_SERVE (VARCHAR(18)) to the name of the current server.
SELECT CURRENT SERVER INTO :APPL_SERVE FROM SYSDUMMY1
The CURRENT TIME special register specifies a time that is based on a reading of the time-of-day clock when the SQL statement is executed at the current server. If this special register is used more than once within a single SQL statement, or used with CURRENT DATE, CURRENT TIMESTAMP, or the CURDATE, CURTIME, or NOW scalar functions within a single statement; all values are based on a single clock reading.28
Using the CL_SCHED table, select all the classes (CLASS_CODE) that start (STARTING) later today. Today's classes have a value of 3 in the DAY column.
SELECT CLASS_CODE FROM CL_SCHED WHERE STARTING > CURRENT TIME AND DAY = 3
The CURRENT TIMESTAMP special register specifies a timestamp that is based on a reading of the time-of-day clock when the SQL statement is executed at the current server. If this special register is used more than once within a single SQL statement, or used with CURRENT DATE, CURRENT TIME, or the CURDATE, CURTIME, or NOW scalar functions within a single statement; all values are based on a single clock reading.29
Insert a row into the IN_TRAY sample table. The value of the RECEIVED column should be a timestamp that indicates when the row was inserted. The values for the other three columns come from the host variables SRC (CHAR(8)), SUB (CHAR(64)), and TXT (VARCHAR(200)).
INSERT INTO IN_TRAY VALUES (CURRENT TIMESTAMP, :SRC, :SUB, :TXT)
The CURRENT TIMEZONE special register specifies the difference between UTC 30 and local time at the current server. The difference is represented by a time duration (a decimal number in which the first two digits are the number of hours, the next two digits are the number of minutes, and the last two digits are the number of seconds). The number of hours is between -24 and 24 exclusive. Subtracting CURRENT TIMEZONE from a local time converts that local time to UTC.
Using the IN_TRAY table, select all the rows from the table and adjust the value to UTC.
SELECT RECEIVED - CURRENT TIMEZONE, SOURCE, SUBJECT, NOTE_TEXT FROM IN_TRAY
The SESSION_USER special register specifies the run-time authorization ID at the current server. The data type of the special register is VARCHAR(128).
The initial value of SESSION_USER for a new connection is the same as the value of the SYSTEM_USER special register. Its value can be changed by invoking the SET SESSION AUTHORIZATION statement.
Select all notes from the IN_TRAY table that the user placed there himself.
SELECT * FROM IN_TRAY WHERE SOURCE = SESSION_USER
The SYSTEM_USER special register specifies the authorization ID that connected to the current server. The data type of the special register is VARCHAR(128).
Select all notes from the IN_TRAY table that the user placed there himself.
SELECT * FROM IN_TRAY WHERE SOURCE = SYSTEM_USER
The USER special register specifies the run-time authorization ID at the current server. The data type of the special register is VARCHAR(18).
The initial value of USER for a new connection is the same as the value of the SYSTEM_USER special register. Its value can be changed by invoking the SET SESSION AUTHORIZATION statement.
Select all notes from the IN_TRAY table that the user placed there himself.
SELECT * FROM IN_TRAY WHERE SOURCE = USER