BULK In-BIND與RECORD(轉)
在PL/SQL中,BULK In-BIND與RECORD,%ROWTYPE是不能在一塊使用的,也就是說,BULK In-BIND只能與簡單型別的陣列一塊使用,這樣導致如果有多個欄位需要用BULK In-BIND來處理的話,程式碼就比較複雜:
declare
type tab_test is table of tmp_0925%rowtype;
v_id tab_test;
cursor cur_aids is select *
from tmp_0925
where rn >= v_begin and rn <= v_end;
begin
open cur_aids;
fetch cur_aids bulk collect into v_id;
v_cnt := v_id.count;
forall j in 1..v_cnt
update test
set (id, name, age) = (select v_id(j).id, v_id(j).name, v_id(j).age from dual)
where id = v_aids(j).id;
commit;
end;
LINE/COL ERROR
-------- -----------------------------------------------------------------
44/21 PLS-00382: expression is of wrong type
44/45 PLS-00436: implementation restriction: cannot reference fields
of BULK In-BIND table of records
如果想避免PLS-00436又想使用FORALL的話,程式碼如下:
declare
type tab_id is table of tmp_0925.id%type;
type tab_name is table of tmp_0925.name%type;
type tab_age is table of tmp_0925.age%type;
v_id tab_id;
v_name tab_name;
v_age tab_age;
cursor cur_aids is select *
from tmp_0925
where rn >= v_begin and rn <= v_end;
begin
open cur_aids;
fetch cur_aids bulk collect into v_id, v_name, v_age;
v_cnt := v_id.count;
forall j in 1..v_cnt
update test
set (id, name, age) = (select v_id(j), v_name(j), v_age(j) from dual)
where id = v_id(j);
commit;
end;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-242235/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- bulk forall 的測試(轉)
- Elasticsearch——mget及bulkElasticsearch
- sqlserver bulk insert報錯Cannot bulk load because the file could not be opened.SQLServer
- screen-record
- Active Record Associations
- react-recordReact
- https與TLS/SSL 握手協議、record protocol簡介HTTPTLS協議Protocol
- 最新kali之bulk_extractor
- mongodb批量操作, bulk_write,MongoDB
- Camera List Record - 120
- Daily record-SeptemberAI
- Learn and Record12
- ES6+ ---- record
- 等待事件wait for a undo record 與 fast_start_parallel_rollback引數事件AIASTParallel
- 實戰 Java 16 值型別 Record - 2. Record 的基本用法Java型別
- Homework record-Simple sorting
- Travel Notes-Record mood
- How to open and close static streams in a USB bulk endpoint
- Java 21 新特性:Record PatternsJava
- gorm忽略報錯: record not foundGoORM
- Java 16 新特性:record類Java
- Erlang中的Record詳解
- Record It for Mac錄屏軟體Mac
- 淺析 record 使用場景
- Renovation Tour-Record my home
- Signac處理bulk ATAC-seq資料
- ElasticSearch7.4批量匯入_bulkElasticsearch
- 【elasticsearch】bulk api奇特的json格式的原因ElasticsearchAPIJSON
- record:記錄(帶名元組)
- 不好分類的好題Record
- PerconaXtraDBClusterGCache和Record-Set快取GC快取
- SAP WM高階之上架策略B (Bulk Storage)
- JDK14 新增關鍵字——recordJDK
- 如何處理 No DMARC Record Found 問題
- libusb:libusb_bulk_transfer的timeout引數問題
- mysql innodb lock鎖之record lock之一MySql
- Yii2 - Active Record 輕鬆學習
- Record Lectures for Mac(日曆錄音軟體)Mac