SET SESSION AUTHORIZATION
Select the user under which database operations are performed in the current connection.
Syntax
SET SESSION AUTHORIZATION TO login [ USING auth ]
- login is the name of the database user.
- auth is the password to authenticate the database user.
Usage
The SET SESSION AUTHORIZATION
instruction switches to the specified database
user in the current database connection. It allows a user to assume the identity of another database
user.
SET SESSION AUTHORIZATION
instruction is specific to IBM® Informix®.If the current database connection is trusted (it was established with a CONNECT TO
using the
TRUSTED
keyword), the SET SESSION AUTHORIZATION
instruction can be
used to switch to a database user associated to the trusted context of the user specified in
CONNECT TO
. The password is optional, if the trusted context defines the user
association is defined WITHOUT AUTHENTICATION
.
If the current database connection is not established for a trusted context, the SET
SESSION AUTHORIZATION
can be used to switch to another database user, with an optional
password.
In both cases, the user specified in CONNECT TO
must have all required database
privileges to switch to the user specified by the SET SESSION AUTHORIZATION
statement.
See Informix database documentation for more details about SET SESSION
AUTHORIZATION
and trusted contexts (CREATE TRUSTED CONTEXT
).
Example
MAIN
DEFINE db, un, pw STRING
LET db = "stores"
LET un = "mike"
LET pw = "..."
CONNECT TO db USER un USING pw TRUSTED
LET un = "scott"
SET SESSION AUTHORIZATION TO un
LET un = "robert"
SET SESSION AUTHORIZATION TO un
END MAIN