FirebirdSQL logo

CURRENT_ROLE

Current explicit role of the connection

Type

VARCHAR(63)

Syntax
CURRENT_ROLE

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

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.

Note

Roles that are active by default and not explicitly specified on connect or using SET ROLE are not returned by CURRENT_ROLE.Use RDB$ROLE_IN_USE to check for all active roles.

Example
if (current_role <> 'MANAGER')
  then exception only_managers_may_delete;
else
  delete from Customers where custno = :custno;
See also

RDB$ROLE_IN_USE

CURRENT_TIME

Current server time in the session time zone, with time zone information

Type

TIME WITH TIME ZONE

Caution

Data type changed in Firebird 4.0 from TIME WITHOUT TIME ZONE to TIME WITH TIME ZONE.Use [fblangref50-contextvars-localtime] to obtain TIME WITHOUT TIME ZONE.

Syntax
CURRENT_TIME [ (<precision>) ]

<precision> ::= 0 | 1 | 2 | 3

The optional precision argument is not supported in ESQL.

Table 1. CURRENT_TIME Parameter
Parameter Description

precision

Precision.The default value is 0.Not supported in ESQL

The default is 0 decimals, i.e. seconds precision.

Note
  • CURRENT_TIME has a default precision of 0 decimals, where CURRENT_TIMESTAMP has a default precision of 3 decimals.As a result, CURRENT_TIMESTAMP is not the exact sum of CURRENT_DATE and CURRENT_TIME, unless you explicitly specify a precision (i.e. CURRENT_TIME(3) or CURRENT_TIMESTAMP(0)).

  • Within a PSQL module (procedure, trigger or executable block), the value of CURRENT_TIME will remain constant every time it is read.If multiple modules call or trigger each other, the value will remain constant throughout the duration of the outermost module.If you need a progressing value in PSQL (e.g. to measure time intervals), use [fblangref50-contextvars-now].

Warning
CURRENT_TIME and Firebird Time Zone Support

Firebird 4.0 added support for time zones.As part of this support, an incompatibility with the CURRENT_TIME expression was introduced compared to previous version.

Since Firebird 4.0, CURRENT_TIME returns the TIME WITH TIME ZONE type.In order for your queries to be compatible with database code of Firebird 4.0 and higher, Firebird 3.0.4 and Firebird 2.5.9 introduced the [fblangref50-contextvars-localtime] expression.In Firebird 3.0.4 and Firebird 2.5.9, LOCALTIME is a synonym for CURRENT_TIME.

In Firebird 5.0, LOCALTIME returns TIME [WITHOUT TIME ZONE]), while CURRENT_TIME returns TIME WITH TIME ZONE.

Examples
select current_time from rdb$database
-- returns e.g. 14:20:19.0000

select current_time(2) from rdb$database
-- returns e.g. 14:20:23.1200