Parsing of Plsql_ dynamic statements (concept)

Source: Internet
Author: User

2014-06-02 Baoxinjian

1. The simplest example

(1). Sql

1 DECLARE2 3L_sql_textVARCHAR( +);4 5TYPE c_type_wip_entity isREFCURSOR;6 7 c_wip_entity c_type_wip_entity;8 9R_wip_entity wip_entities%ROWTYPE;Ten  One BEGIN A  -L_sql_text:='SELECT * from Wip_entities' -  the                    || 'where wip_entity_id in ('|| " '"|| '2363' || " ","' '|| '2462'|| " ")'; -  - Dbms_output.put_line (l_sql_text); -  +     OPENC_wip_entity forL_sql_text; -  + LOOP A  at    FETCHC_wip_entity intor_wip_entity; -  -         EXIT  whenC_wip_entity%NOTFOUND; -  -Dbms_output.put_line ('Job name-->' ||r_wip_entity.wip_entity_name); -  in     ENDLOOP; -  to END;

(2). DBMS Output

2. dynamic statements combined with batch processing

(1). Sql

1 DECLARE2 3I Number;4 5L_sql_textVARCHAR( +);6 7TYPE c_type_wip_entity is TABLE  ofWip_entities%ROWTYPE;8 9 c_wip_entity c_type_wip_entity;Ten  Onep_wip_entity_id Number:= 2363; A  - BEGIN -  theL_sql_text:= 'SELECT * from wip_entities where wip_entity_id =: wip_entity_id'; -  -     EXECUTEIMMEDIATE L_sql_text -  +     BULKCOLLECT intoc_wip_entity -  + USING p_wip_entity_id; A  at      forIinch 1.. C_wip_entity.COUNT -  - LOOP -  - Dbms_output.put_line (c_wip_entity (i). Wip_entity_name); -  in     ENDLOOP; -  to END;

(2). DBMS Output

3. Dynamic Update statements

(1). Sql

1 DECLARE2 3L_sql_textVARCHAR( +);4 5 BEGIN6 7L_sql_text:= 'Update cux_wf_demo_documents Set note=' || " "Test" " || 'where document_id=:d ocument_id';8 9     EXECUTEIMMEDIATE L_sql_textTen  OneUSING1; A  - Dbms_output.put_line (l_sql_text); -  the END;

(2). DBMS Output

Thanks and Regarads

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.