DB2 Version 9.7 for Linux, UNIX, and Windows

CURRENT USER special register

The CURRENT USER (or CURRENT_USER) special register specifies the authorization ID that is used for statement authorization for the statement in which it was referenced. For dynamic SQL statements, the value depends on the dynamic SQL statement behavior in effect for the package issuing the dynamic SQL statement in which this special register is referenced. See "Effect of DYNAMICRULES bind option on dynamic SQL" for details. The data type of the register is VARCHAR(128). If the length of the authorization ID is less than 8 bytes, the special register value is padded with trailing blanks such that the length is 8 bytes.

Example: Select table names whose schema matches the value of the CURRENT USER special register.
   SELECT TABNAME FROM SYSCAT.TABLES 
     WHERE TABSCHEMA = CURRENT USER AND TYPE = 'T'
If this statement is executed as a static SQL statement, it returns the tables whose schema name matches the binder of the package that includes the statement. If this statement is executed as a dynamic SQL statement using dynamic SQL statement run behavior, it returns the tables whose schema name matches the current value of the SESSION_USER special register.