disable/enable constraints

CREATE OR REPLACE PROCEDURE sp_dat_disable_constraints
IS
BEGIN
FOR i IN (SELECT table_name, constraint_name FROM user_constraints WHERE owner=’DAT’ AND constraint_type=’R’ AND status=’ENABLED’) LOOP
EXECUTE IMMEDIATE ‘ALTER TABLE ‘ || i.TABLE_NAME || ‘ DISABLE CONSTRAINT ‘ || i.constraint_name;
END LOOP i;
END;

CREATE OR REPLACE PROCEDURE sp_dat_enable_constraints
IS
BEGIN
FOR i IN (SELECT table_name, constraint_name FROM user_constraints WHERE owner=’DAT’ AND status=’DISABLED’) LOOP
EXECUTE IMMEDIATE ‘ALTER TABLE ‘ || i.TABLE_NAME || ‘ ENABLE CONSTRAINT ‘ || i.constraint_name;
END LOOP i;
END;