Question & Answer
Question
CURRENT_USER usage considerations
Answer
With IBM i 7.2, DB2 for i added CURRENT_USER to its list of supported special registers.
Table 1 shows a simple description of the different special registers that can be used to extract user identity information within SQL. The SQL Reference includes more details on special registers and CURRENT_USER.

When special registers are referenced within global variable default values, users should understand that global variables are typically instantiated a single time within a job (or session). That means that if you reference identity information within the global variable default value, the identity in place within the job on the first reference will apply. Subsequent references to the global variable will not cause the default expression to be re-evaluated.
Additionally, since CURRENT_USER provides some insight into the adopted authority in effect, users should also be aware that global variables default values exist within a *SRVPGM executable object that is built to use adopted authority when the default expression is evaluated. Therefore, global variable default values would always return the authorization ID of the owner of the global variable as the CURRENT_USER.
Was this topic helpful?
Document Information
Modified date:
18 December 2019
UID
nas8N1020203