execute immediate 语法小结
查询语句:
单条记录:
execute immediate
'select a.dummy from dual' into v_dummy;
多条记录:
execute immediate
'select dbms_random.value(0,1) from dual connect by rownum <= 10'
bulk collect into v_dummy;
使用绑定变量:
execute immediate
'select dbms_random.value(0,1) from dual connect by rownum <= :1'
bulk collect into v_dummy
using rowcnt;
更新语句:
更新并获取单个所更新记录:
execute immediate
'update test t set t.flag = 1 where t.id = 10 returning t.name into :1'
returning into v_name;
更新并获取多个所更新记录:
execute immediate
'update test t set t.flag = 1 where t.name like ''jack%'' returning t.name into :1'
returning bulk collect into v_names;
delete和insert 语句与update基本类似。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12932950/viewspace-624250/,如需转载,请注明出处,否则将追究法律责任。