Using (dynamic statement)

Source: Internet
Author: User

Using (dynamic statement) [SQL] -- create test table create table t01 (id integer, name varchar2 (10); www.2cto.com -- create test data insert into t01 (id, name) values (1, 'A'); insert into t01 (id, name) values (2, 'B'); insert into t01 (id, name) values (3, 'C'); -- submit commit; -- query the table data select * from t01; -- use a dynamic statement to assign a value to the variable www.2cto.com declare id t01.id % type: = '1 '; name t01.name % type; begin execute immediate 'select name from t01 t where id =: 1 'into name using id; dbms_output.put_line (name); end; -- use a dynamic statement to insert data declare id t01.id % type: = 4; name t01.name % type: = 'D'; begin execute immediate 'insert into t01 (id, name) values (: 1,: 2) 'using id, name; commit; end; -- use a dynamic statement to update the data declare id t01.id % type: = 3; name t01.name % type: = 'D '; begin execute immediate 'Update t01 set name =: 1 where id =: 2' using name, id; commit; end; -- use a dynamic statement to delete data declare id t01.id % type: = 4; begin execute immediate 'delete from t01 where id =: 1 'using id; commit; end;

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.