PolarDB for PostgreSQL(Compatible with Oracle) provides the DBMS_SESSION.SET_ROLE stored procedure.

Functions and stored procedures

Function or stored procedureReturn value typeDescription
SET_ROLE(role_cmd)N/AExecutes the SET_ROLE statement followed by the string value specified in role_cmd.

The DBMS_SESSION stored procedure in PolarDB for PostgreSQL(Compatible with Oracle) is partially implemented when compared with Oracle's version. Only DBMS_SESSION.SET_ROLE is supported.

SET_ROLE

The SET_ROLE stored procedure sets the current session user to the role specified in role_cmd. After the current session invokes the SET_ROLE stored procedure, the session uses the permissions assigned to the specified role. The syntax for this stored procedure:

SET_ROLE(role_cmd)

The SET_ROLE stored procedure appends the value specified for role_cmd to the SET ROLE statement, and then invokes the statement.

Parameters

ParameterDescription
role_cmdSpecifies a role name in the form of a string value.

Examples

The following example demonstrates a call to the SET_ROLE stored procedure which uses the SET_ROLE statement to set the identity of the current session user to manager.

exec DBMS_SESSION.SET_ROLE('manager');