You use SET SESSION AUTHORIZATION to define the current authorization identifier for the SQL session.
The current authorization code of an SQL session is defined either with an ESQL precompiler option or with the SET SESSION AUTHORIZATION statement. If no authorization code is defined at either place, the default value D0USER
is used as the current authorization code for the SQL session.
The setting determined by SET SESSION AUTHORIZATION is revoked when the immediately following transaction - the current UTM transaction in the case of openUTM - is rolled back. This is also true if the immediately following transaction only contains CALL DML statements.
Otherwise the authorization key you set with SET SESSION AUTHORIZATION is valid until a new authorization key is set with SET SESSION AUTHORIZATION or until the end of the SQL session.
The SET SESSION AUTHORIZATION does not initiate a transaction and can therefore only be used outside of an SQL transaction.
SET SESSION AUTHORIZATION
new_authorization_identifier
new_authorization_identifier ::= {
alphanumeric_literal | :
host_variable }
new_authorization_identifier
Name of the new authorization identifier that is to be valid for the SQL session. The new authorization identifier is valid until the next SET SESSION AUTHORIZATION statement.
alphanumeric_literal
The new authorization identifier is specified as an alphanumeric literal (not in the hexadecimal format) of the data type CHAR.
host_variable
The new authorization identifier is specified as an alphanumeric host variable of the type CHAR or VARCHAR. The host variable cannot be a vector and cannot have an associated indicator variable.
Examples
Define a new authorization identifier UTIADM for the current SQL session. The current UTM or BS2000 user must have a system entry with this authorization identifier.
SET SESSION AUTHORIZATION 'utiadm'
Specify the authorization identifier for the current SQL session as a host variable.
SET SESSION AUTHORIZATION :USER-NAME