Create Or Replace Procedure P_change_fk_status (in_table In Varchar2 , In_type In Varchar2 , In_action In Varchar2 ) Is -- Invalid or valid foreign key of the specified table -- In_table: Table Name -- In_type: R must represent the foreign key. -- In_action: Disable or enable V_table Varchar2 ( 30 ); V_action Varchar2 ( 10 ); V_ SQL Varchar2 ( 200 ); V_fk Varchar2 (60 ); Begin V_table: = Substr (in_table, 2 , Length (in_table) - 2 ); V_action: = Substr (in_action, 2 , Length (in_action) - 2 ); -- Query foreign key names V_ SQL: = ' Select constraint_name from user_constraints where constraint_type = ' | In_type | ' And table_name = ' | In_table; dbms_output.put_line ( ' V_ SQL: ' | V_ SQL ); Execute Immediate v_ SQL Into V_fk; v_ SQL: = ' ALTER TABLE ' | V_table | ' ' | V_action | ' Constraint ' | V_fk; dbms_output.put_line ( ' V_ SQL: ' | V_ SQL ); Execute Immediate v_ SQL; End P_change_fk_status;
Run