Use Oracle's dynamic SQL support

Source: Internet
Author: User

Oracle dynamic SQL

  • Dbms_ SQL built-in package
  • Native dynamic SQL

Three common functions of native dynamic SQL

  • Execute dynamic DDL or DML statements that do not contain Bound variables.
  • Execute dynamic DDL or DML containing Bound variables
  • Dql support, Data Query Language

Scenario/simple process

Code

Declare tmpstr varchar2 (4000): = NULL; tmpi number (10): = 0; begin for C in (select B. table_name BTN from user_constraints a left join user_constraints B on. owner = B. owner and B. R _ constraint_name =. constraint_name where. owner = 'nstcsa224 'and. table_name = 'cpm _ branch') loop if (C. BTN is not null) Then tmpstr: = 'in in select count (*) into: CC from' | C. BTN | '; end;'; execute immediate tmpstr using out tmpi; dbms_output.put_line ('SQL statement:' | tmpstr); dbms_output.put_line ('table name: '| C. BTN | 'data: '| tmpi); end if; end loop; Exception when others then dbms_output.put_line (sqlerrm); end;

References

1. Oracle Database 10g PL/SQL

 

Related Article

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.