【筆記】forall and nested table and cursor
CREATE TYPE Coords AS OBJECT (x NUMBER, y NUMBER);
CREATE TABLE test_grid (num NUMBER, loc Coords);
INSERT INTO test_grid VALUES(10, Coords(1,2));
INSERT INTO test_grid VALUES(20, Coords(3,4));
DECLARE
TYPE CoordsTab IS TABLE OF Coords;
pairs CoordsTab;
BEGIN
SELECT loc BULK COLLECT INTO pairs FROM test_grid;
-- now pairs contains (1,2) and (3,4)
END;
DECLARE
TYPE NameList IS TABLE OF emp.ename%TYPE;
TYPE SalList IS TABLE OF emp.sal%TYPE;
CURSOR c1 IS
SELECT ename, sal FROM emp WHERE sal > 1000;
names NameList;
sals SalList;
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT
INTO names, sals;
END;
DECLARE
TYPE DeptRecTab IS TABLE OF dept%ROWTYPE;
dept_recs DeptRecTab;
CURSOR c1 IS
SELECT deptno, dname, loc FROM dept WHERE deptno > 10;
BEGIN
OPEN c1;
FETCH c1 BULK COLLECT
INTO dept_recs;
END;
forall和bulk conect 結合
FORALL j IN depts.FIRST..depts.LAST
DELETE FROM emp WHERE empno = depts(j)
RETURNING empno BULK COLLECT INTO enums;
錯誤注意:
All targets in a BULK COLLECT INTO clause must be collections, as the
following example shows:
DECLARE
TYPE NameList IS TABLE OF emp.ename%TYPE;
names NameList;
salary emp.sal%TYPE;
BEGIN
SELECT ename, sal BULK COLLECT
INTO names, salary -- illegal target
FROM emp
WHERE ROWNUM < 50;
END;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/16179598/viewspace-582299/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【筆記】forall 異常捕獲筆記
- 資料庫表--nested table資料庫
- 從共享遊標shared cursor角度看forall批量繫結
- ES 筆記四十二:物件及 Nested 物件筆記物件
- 【筆記】使用 plan_table筆記
- Bootstrap Table 學習筆記之列引數(一)boot筆記
- Android學習過程的Cursor遊標填坑筆記Android筆記
- Data Warehouse Guide閱讀筆記(七):partition tableGUIIDE筆記
- NGUI學習筆記(六):ScrollView、Grid和TableNGUI筆記View
- FORALL執行DELETE語句delete
- FORALL執行UPDATE語句
- MySQL中的derived table(r12筆記第47天)MySql筆記
- nested loop心得OOP
- FORALL執行UPDATE語句(二)
- 使用BULK COLLECT+FORALL加速批量提交
- 連續插值,用forall實現。
- table column histogram .親自實驗檢驗得出的學習筆記。Histogram筆記
- MySQL 8.0 Reference Manual(讀書筆記78節-- InnoDB Table and Page Compression (1))MySql筆記
- MySQL 8.0 Reference Manual(讀書筆記79節-- InnoDB Table and Page Compression (2))MySql筆記
- pl/sql中的forall簡單測試SQL
- PL/SQL 批次Bind Forall 的效能表現SQL
- forall_for loop效能對比測試_plsqlOOPSQL
- shared SQL,parent cursor,child cursorSQL
- ElasticSearch多層nested查詢、nested過濾排除非結果內容Elasticsearch
- 【CURSOR】Oracle 遊標 (cursor)知識梳理Oracle
- 【sql調優之執行計劃】nested loops join and nested loop join outerSQLOOP
- NESTED LOOPS 成本計算OOP
- Oracle CursorOracle
- Cursor使用
- oracle實驗記錄 (cursor_sharing(2)SIMILAR)OracleMILA
- open_cursor & session_cached_cursor實驗Session
- 理解V$OPEN_CURSOR,SESSION_CACHED_CURSORSession
- zt_小荷_記得cursor pin s wait on xAI
- 理解V$OPEN_CURSOR, V$SESSION_CACHED_CURSORSession
- treevalue——Master Nested Data Like TensorAST
- HASH JOIN ,MERGE JOIN ,NESTED LOOPOOP
- [轉]Trees in SQL: Nested Sets and Materialized PathSQLZed
- PL/SQL cursorSQL