-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy path11g_field_of_record.sql
More file actions
39 lines (32 loc) · 1.02 KB
/
Copy path11g_field_of_record.sql
File metadata and controls
39 lines (32 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CREATE OR REPLACE FUNCTION apply_cola (salary_in IN NUMBER)
RETURN NUMBER
IS
BEGIN
RETURN salary_in * 2;
END;
/
DECLARE
TYPE two_columns_rt IS RECORD (
employee_id employees.employee_id%TYPE
, salary employees.salary%TYPE
);
TYPE id_name_list_tt IS TABLE OF two_columns_rt INDEX BY PLS_INTEGER;
l_list id_name_list_tt;
BEGIN
SELECT employee_id, salary
BULK COLLECT INTO l_list FROM employees;
FOR idx IN 1 .. l_list.COUNT LOOP
l_list (idx).salary := apply_cola (l_list (idx).salary);
END LOOP;
FORALL idx IN 1 .. l_list.COUNT
UPDATE employees SET salary = l_list (idx).salary
WHERE employee_id = l_list (idx).employee_id;
END;
/
ROLLBACK;
/*======================================================================
| Supplement to the fifth edition of Oracle PL/SQL Programming by Steven
| Feuerstein with Bill Pribyl, Copyright (c) 1997-2009 O'Reilly Media, Inc.
| To submit corrections or find more code samples visit
| http://oreilly.com/catalog/9780596514464/
*/