select 'vdb'::name as "PKTABLE_CAT",
n2.nspname as "PKTABLE_SCHEM",
c2.relname as "PKTABLE_NAME",
a2.attname as "PKCOLUMN_NAME",
'vdb'::name as "FKTABLE_CAT",
n1.nspname as "FKTABLE_SCHEM",
c1.relname as "FKTABLE_NAME",
a1.attname as "FKCOLUMN_NAME",
i::int2 as "KEY_SEQ",
case ref.confupdtype
when 'c' then 0::int2
when 'n' then 2::int2
when 'd' then 4::int2
when 'r' then 1::int2
else 3::int2
end as "UPDATE_RULE",
case ref.confdeltype
when 'c' then 0::int2
when 'n' then 2::int2
when 'd' then 4::int2
when 'r' then 1::int2
else 3::int2
end as "DELETE_RULE",
ref.conname as "FK_NAME",
cn.conname as "PK_NAME",
case
when ref.condeferrable then
case
when ref.condeferred then 5::int2
else 6::int2
end
else 7::int2
end as "DEFERRABILITY"
from
((((((( (select cn.oid, conrelid, conkey, confrelid, confkey,
generate_series(array_lower(conkey, 1), array_upper(conkey, 1)) as i,
confupdtype, confdeltype, conname,
condeferrable, condeferred
  from pg_catalog.pg_constraint cn,
pg_catalog.pg_class c,
pg_catalog.pg_namespace n
  where contype = 'f'
  and confrelid = c.oid
  and relname = 'PARTSSUPPLIER.STATUS'
  and n.oid = c.relnamespace
  and n.nspname = 'PartsSupplier'
) ref
inner join pg_catalog.pg_class c1
  on c1.oid = ref.conrelid)
inner join pg_catalog.pg_namespace n1
  on n1.oid = c1.relnamespace)
inner join pg_catalog.pg_attribute a1
  on a1.attrelid = c1.oid
  and a1.attnum = conkey[i])
inner join pg_catalog.pg_class c2
  on c2.oid = ref.confrelid)
inner join pg_catalog.pg_namespace n2
  on n2.oid = c2.relnamespace)
inner join pg_catalog.pg_attribute a2
  on a2.attrelid = c2.oid
  and a2.attnum = confkey[i])
left outer join pg_catalog.pg_constraint cn
  on cn.conrelid = ref.confrelid
  and cn.contype = 'p')
  order by ref.oid, ref.i