|
|
|
A m Z o n e
Loading huge volume of data into PL/SQL table at one shot (Bulk Collect)
Is it possible to assign huge volume of data to a PL/SQL table, without using the conventional method of looping?
Use Bulk Collects
In the previous article (Bulk Binds), the list with empno's was statically built.
With Bulk Collect you can dynamically build the entire list using "bulk collect into" option.
Bulk collects updated value returnDECLARE TYPE Numlist IS TABLE OF emp.empno%TYPE; Id Numlist; BEGIN SELECT empno BULK COLLECT INTO Id FROM emp WHERE sal < 2000; FORALL i IN Id.FIRST..Id.LAST UPDATE emp SET Sal = 1.1 * Sal WHERE mgr = Id(i); END; /
In the PL/SQL table "Bonlist" you can now find the updated salaries.DECLARE TYPE Numlist IS TABLE OF emp.empno%TYPE; TYPE Bonlist IS TABLE OF emp.sal%TYPE; Id Numlist; Bl Bonlist; BEGIN SELECT empno BULK COLLECT INTO Id FROM emp WHERE deptno = 10; FORALL i IN Id.FIRST..Id.LAST UPDATE emp SET Sal = 1.1 * Sal WHERE mgr = Id(i) RETURNING Sal BULK COLLECT INTO Bl; END; /
Press the Back button of you Browser to go to previous page
Home