CREATE OR REPLACE FORCE VIEW "PLANTA_NULL_FKS" ("TABLE_ID", "R_TABLE_ID", "RELATION", "RECURSION", "NAME", "FIRST_KEY_DI", "LAST_KEY_DI", "FIRST_DB_POS", "LAST_DB_POS") AS 
select "TABLE_ID","R_TABLE_ID","RELATION","RECURSION","NAME","FIRST_KEY_DI","LAST_KEY_DI","FIRST_DB_POS","LAST_DB_POS" from planta_fks fk
where exists (
  select 1 from planta_tables t
  where t.id = fk.r_table_id
  and t.has_dummy = 1
)
order by fk.table_id, fk.r_table_id, fk.first_key_di;/
