9.3. CURRENT_ROLE

Available in

DSQL, PSQL

Syntax

  1. CURRENT_ROLE

Type

VARCHAR(31)

Description

CURRENT_ROLE is a context variable containing the role of the currently connected user. If there is no active role, CURRENT_ROLE is 'NONE'.

Example

  1. if (current_role <> 'MANAGER')
  2. then exception only_managers_may_delete;
  3. else
  4. delete from Customers where custno = :custno;

CURRENT_ROLE always represents a valid role or 'NONE'. If a user connects with a non-existing role, the engine silently resets it to 'NONE' without returning an error.