Computed fields are readonly. I need to find all such fields in specific table.
This query solves this problem (returns info if column is computed or not):
select r.rdb$field_name, r.rdb$update_flag from rdb$relation_fields r where r.rdb$relation_name = 'specific_table'
At least it looks like it solves it, but it seems that returned informations are incorrect.
When RDB$UPDATE_FLAG
is 0
, its computed (readonly). But its 0
even for normal columns.
Advertisement
Answer
If you wanted computed fields instead – that is what you have to query for, the expression used to compute.
RDB$FIELDS
stores definitions of columns and domains, both system and custom. This is where the detailed data attributes are stored for all columns.The column
RDB$FIELDS.RDB$FIELD_NAME
links toRDB$RELATION_FIELDS.RDB$FIELD_SOURCE
RDB$COMPUTED_BLR
– The binary language representation (BLR) of the SQL expression the database server uses for evaluation when accessing aCOMPUTED BY
column
Hence, something like this should work:
select r.rdb$field_name --, r.rdb$update_flag from rdb$relation_fields r, RDB$FIELDS f where r.rdb$relation_name = 'specific_table' and f.RDB$FIELD_NAME = r.RDB$FIELD_SOURCE and f.RDB$COMPUTED_BLR is not NULL
P.S. https://github.com/FirebirdSQL/firebird-documentation/issues/157