Is it possible to search for all dependencies of a field

1.8k Views Asked by At

I am searching for a specific line in my database and wanted to know if there is a function in ibexpert to look up for all dependencies of a field.

2

There are 2 best solutions below

1
Val Marinov On BEST ANSWER

When field is selected in table click on "Field dependencies" tab.

enter image description here

1
Mark Rotteveel On

I don't know IBExpert, but generically in Firebird, you can find dependencies in the system table RDB$DEPENDENCIES. It won't tell you exactly on which line of code a field is used, but it will help you identify in what object it is used. Then it is a matter of inspecting the source code of that specific object to see where it's used.

The table RDB$DEPENDENCIES has the following columns (in Firebird 2.5):

  • RDB$DEPENDENT_NAME - The name of the 'dependent' (the object using the dependency), eg a stored procedure name
  • RDB$DEPENDED_ON_NAME - The name of the dependency (eg table name)
  • RDB$FIELD_NAME - The field name of a dependency (eg table column); can be NULL for non-field dependencies
  • RDB$DEPENDENT_TYPE - Type of the dependent (eg 0 = relation (table or view), see RDB$TYPES with RDB$FIELD_NAME = 'RDB$OBJECT_TYPE for possible values)
  • RDB$DEPENDED_ON_TYPE - Type of the dependency (column dependencies have type 0 and RDB$FIELD_NAME not null, table/view dependencies have type 0 and RDB$FIELD_NAME null.

As an example, you can use the following query:

select dep.*, tt.RDB$TYPE_NAME as DEPENDENT_OBJECT_TYPE, dt.RDB$TYPE_NAME as DEPENDED_ON_OBJECT_TYPE
from RDB$DEPENDENCIES dep
inner join RDB$TYPES tt
  on tt.RDB$TYPE = dep.RDB$DEPENDENT_TYPE 
    and tt.RDB$FIELD_NAME = 'RDB$OBJECT_TYPE'
inner join RDB$TYPES dt
  on dt.RDB$TYPE = dep.RDB$DEPENDED_ON_TYPE 
    and dt.RDB$FIELD_NAME = 'RDB$OBJECT_TYPE'