-- Enable all NItil FK

declare
l_str_sel_cur varchar2(4000);
l_str_sql_ddl varchar2(4000);
l_constraint_name user_constraints.constraint_name%TYPE;
l_table_name user_constraints.table_name%TYPE;

type t_cur_fk is ref cursor;
cur_fk t_cur_fk;

begin

l_str_sel_cur:= 'select fk.constraint_name , fk.table_name from user_constraints fk where fk.CONSTRAINT_TYPE = ''R''';

open cur_fk for l_str_sel_cur;
loop
fetch cur_fk into l_constraint_name, l_table_name;
exit when cur_fk%notfound;
l_str_sql_ddl := 'ALTER TABLE NITIL.'|| l_table_name ||' MODIFY CONSTRAINT '||l_constraint_name||' ENABLE';
execute immediate l_str_sql_ddl;
end loop;
close cur_fk;
end;
