Взято из IBExperta:

select G.RDB$GENERATOR_NAME from RDB$GENERATORS G where G.RDB$SYSTEM_FLAG is null and not exists( select D1.RDB$DEPENDENT_NAME, D1.RDB$FIELD_NAME, D1.RDB$DEPENDENT_TYPE, R1.rdb$relation_name
  from RDB$DEPENDENCIES D1
left join rdb$relations r1 on ((D1.RDB$DEPENDENT_NAME = r1.rdb$relation_name) and (not (r1.Rdb$View_Blr is null)))
  where (D1.RDB$DEPENDED_ON_TYPE = 14)
  and (D1.RDB$DEPENDENT_TYPE <> 3)
  and (D1.RDB$DEPENDED_ON_NAME = G.RDB$GENERATOR_NAME)
  union
select distinct f2.rdb$relation_name, d2.rdb$field_name, d2.rdb$dependent_type, r2.rdb$relation_name
  from rdb$dependencies d2, rdb$relation_fields f2
left join rdb$relations r2 on ((f2.rdb$relation_name = r2.rdb$relation_name) and (not (r2.Rdb$View_Blr is null)))
  where (d2.rdb$dependent_type = 3) and
  (d2.rdb$dependent_name = f2.rdb$field_source)
  and (d2.rdb$depended_on_name = G.RDB$GENERATOR_NAME)
)

Марат.

Ответить