Sql 通过这种方式,我们可以在动态游标中使用批量删除吗?
我们可以像使用游标一样使用executeimmediate进行批量删除吗Sql 通过这种方式,我们可以在动态游标中使用批量删除吗?,sql,plsql,oracle10g,oracle11g,Sql,Plsql,Oracle10g,Oracle11g,我们可以像使用游标一样使用executeimmediate进行批量删除吗 forall i in rowid.FIRST .. rowid.LAST Execute Immediate 'DELETE table_name '||PARTIION_NAME||'where rowid =rowid(m)'; 有没有其他方法做这项工作。。。? 提前谢谢我真的不明白你想用| |分区|名称| | |做什么,但你可以这样做: DECLARE type rowid_tab is table of r
forall i in rowid.FIRST .. rowid.LAST
Execute Immediate 'DELETE table_name '||PARTIION_NAME||'where rowid =rowid(m)';
有没有其他方法做这项工作。。。?
提前谢谢我真的不明白你想用| |分区|名称| | |做什么,但你可以这样做:
DECLARE
type rowid_tab is table of rowid;
rowids rowid_tab;
cursor c is select rowid from table_name where <some condition>;
BEGIN
open c;
fetch c bulk collect into rowids;
close c;
-- here is where the "real thing" starts
forall i in rowids.first .. rowids.last
execute immediate 'delete table_name where rowid = :1' using rowids(i);
commit;
END;
但我必须问一下——为什么?分区的名称是什么?常数?参数?rowidm中的m是什么?为什么在删除时使用..:1?在以您的格式执行查询时,最好在动态sql性能和安全性中使用绑定变量..它给了我缺少的格式ORA:06512您能给我们完整的代码吗?顺便说一句,我仍然不明白为什么要使用动态sql,为什么不首先为rowids中的所有I使用。。rowids.last delete table_name,其中rowid=rowidsi?我们可以使用EXECUTE IMMEDIATE而不使用绑定变量吗