The foreign key of the specified table is invalid or takes effect in Oracle Stored Procedure exercise series.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.