SQL$HELP_OLD72.HLB  —  Built In Functions, BITSTRING
    The BITSTRING function extracts selected bits from a binary data
    value. This functionality is primarily intended to query the bit
    values stored in the RDB$FLAGS columns in the Rdb system table,
    but can also be used for user data.

    BITSTRING accepts numeric and date/time values and processes them
    as bit arrays. The first (least significant) bit is numbered 1.
    The most significant bit depends on the data type.

    o  TINYINT has 8 bits

    o  SMALLINT has 16 bits

    o  INTEGER has 32 bits

    o  BIGINT, DATE, TIME, TIMESTAMP and INTERVAL types have 64 bits

    o  The numeric expression after the FOR and FROM keywords must be
       unscaled numeric values.

    The following notes apply to usage of the BITSTRING function:

    o  If the numeric expression of the FOR clause is less than equal
       to zero then it will be assumed equal to 1.

    o  If the FOR clause is omitted it will default to a value that
       includes all remaining bits of the source value.

    o  If the FOR clause specifies a larger value than the number
       of bits remaining in the source then will only return the
       remaining bits.

    Example: Using the BITSTRING function

    Bit 1 in the RDB$FLAGS column of RDB$RELATIONS indicates that the
    table is a view. This example uses this query to fetch the names
    of all user defined views in the PERSONNEL database.

    SQL> select rdb$relation_name
    cont> from rdb$relations
    cont> where rdb$system_flag = 0 and
    cont>     bitstring (rdb$flags from 1 for 1) = 1;
     RDB$RELATION_NAME
     CURRENT_JOB
     CURRENT_SALARY
     CURRENT_INFO
    3 rows selected
    SQL>
Close Help