Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 通过这种方式,我们可以在动态游标中使用批量删除吗?_Sql_Plsql_Oracle10g_Oracle11g - Fatal编程技术网

Sql 通过这种方式,我们可以在动态游标中使用批量删除吗?

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

我们可以像使用游标一样使用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 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而不使用绑定变量吗