Author Topic: Get generator name on a column in Firebird  (Read 1724 times)


  • Full Member
  • ***
  • Posts: 139
Get generator name on a column in Firebird
« on: June 21, 2021, 07:50:52 pm »
Just wanted to show how i did it with Zeos.
Maybe it can be a help to someone.
It was not easy to find out how to do it.

I used a ZQuery, and used two parameters.

I added this SQL text in the SQL component.

SELECT trigdep.rdb$depended_on_name AS fgenerator
        FROM rdb$dependencies tabdep
             JOIN rdb$dependencies trigdep ON (tabdep.rdb$dependent_name=trigdep.rdb$dependent_name
               AND trigdep.rdb$depended_on_type=14
               AND trigdep.rdb$dependent_type=2)
             JOIN rdb$triggers trig ON (trig.rdb$trigger_name=tabdep.rdb$dependent_name)
        WHERE tabdep.rdb$depended_on_name=:TBLNAME
          AND tabdep.rdb$depended_on_type=0
          AND trig.rdb$trigger_type=1
          AND tabdep.rdb$field_name=:FIELDNAME
          AND (SELECT count(*)
               FROM rdb$dependencies trigdep2
               WHERE trigdep2.rdb$dependent_name = trigdep.rdb$dependent_name) = 2

When opening the ZQuery, i now get the generator name on each column if it has any.

In Firebird 3, it is also a new type of generator implementation(default auto increment). And also have new columns added in the RDB$RELATION_FIELDS. RDB$GENERATOR_NAME and RDB$IDENTITY_TYPE that is used with this new implementation.
I have not looked at this yet.
« Last Edit: June 21, 2021, 07:52:52 pm by Fantablup »


TinyPortal © 2005-2018