Some Special Registers in SQL DB2 for i SQL |
We can use certain Special registers in our SQL queries. For example, CURRENT DATE, CURRENT TIME etc. that contains information that can be referenced in the SQL queries.
Special Register
Some of the special register we use are listed here:
SELECT current date FROM sysibm.sysdummy1
Or
SELECT current_date FROM sysibm.sysdummy1
Output:
CURRENT DATE 02/14/24
SELECT current time FROM sysibm.sysdummy1
Or
SELECT current_time FROM sysibm.sysdummy1
Output:
CURRENT TIME 21:49:31
SELECT current timestamp FROM sysibm.sysdummy1
Or
SELECT current_timestamp FROM sysibm.sysdummy1
Output:
CURRENT TIMESTAMP 2024-02-14-21.50.51.975954
SELECT current user FROM sysibm.sysdummy1
Or
SELECT current_user FROM sysibm.sysdummy1
Output:
CURRENT USER EASYCLASS
SELECT user FROM sysibm.sysdummy1
Or
SELECT session_user FROM sysibm.sysdummy1
Output:
SESSION_USER EASYCLASS
SELECT SYSTEM_USER FROM sysibm.sysdummy1
Output:
SYSTEM_USER EASYCLASS