FirebirdSQL logo

Examples of MAKE_DBKEY

  1. Select record using relation name (note that relation name is uppercase)

    select *
    from rdb$relations
    where rdb$db_key = make_dbkey('RDB$RELATIONS', 0)
  2. Select record using relation ID

    select *
    from rdb$relations
    where rdb$db_key = make_dbkey(6, 0)
  3. Select all records physically residing on the first data page

    select *
    from rdb$relations
    where rdb$db_key >= make_dbkey(6, 0, 0)
    and rdb$db_key < make_dbkey(6, 0, 1)
  4. Select all records physically residing on the first data page of 6th pointer page

    select *
    from SOMETABLE
    where rdb$db_key >= make_dbkey('SOMETABLE', 0, 0, 5)
    and rdb$db_key < make_dbkey('SOMETABLE', 0, 1, 5)

RDB$ERROR()

Returns PSQL error information inside a WHEN …​ DO block

Available in

PSQL

Result type

Varies (see table below)

Syntax
RDB$ERROR (<context>)

<context> ::=
  GDSCODE | SQLCODE | SQLSTATE | EXCEPTION | MESSAGE
Table 1. Contexts
Context Result type Description

GDSCODE

INTEGER

Firebird error code, see also GDSCODE

SQLCODE

INTEGER

(deprecated) SQL code, see also SQLCODE

SQLSTATE

CHAR(5) CHARACTER SET ASCII

SQLstate, see also SQLSTATE

EXCEPTION

VARCHAR(63) CHARACTER SET UTF8

Name of the active user-defined exception or NULL if the active exception is a system exception

MESSAGE

VARCHAR(1024) CHARACTER SET UTF8

Message text of the active exception

RDB$ERROR returns data of the specified context about the active PSQL exception.Its scope is confined to exception-handling blocks in PSQL (WHEN …​ DO).Outside the exception handling blocks, RDB$ERROR always returns NULL.This function cannot be called from DSQL.