2012-05-24 21 views
0

我們可以使用即時執行批量刪除等(光標)這樣我們可以在動態光標中使用批量刪除嗎?

forall i in rowid.FIRST .. rowid.LAST 
Execute Immediate 'DELETE table_name '||PARTIION_NAME||'where rowid =rowid(m)'; 

有沒有另一種方法做這個工作...? 由於事先

+2

什麼是'PARTITION_NAME'?一個常數?一個參數?什麼是'M'(如ROWID(M) –

+0

其表分區 – user1403174

回答

0

我不真的明白你在試圖與||PARTIION_NAME||做什麼,但你可以做這樣的事情:

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; 

但我必須要問 - 爲什麼?

+0

爲什麼我們使用..:?1,同時刪除 – user1403174

+2

這是更好地使用動態SQL(綁定變量的性能和安全性) –

+0

在執行查詢?在format..it是給我丟失格式ORA:06512 – user1403174

相關問題