文 修改源:http://www.itpub.net/thread-1941544-1-1.html
----创建一张简单的数据表
点击(此处)折叠或打开
- --drop table plch_employees;
- CREATE TABLE plch_employees
- (
- employee_id INTEGER
- , last_name VARCHAR2 (100)
- , salary NUMBER
- )
- /
点击(此处)折叠或打开
- BEGIN
- INSERT INTO plch_employees
- VALUES (100, 'Jobs', 1000000);
-
- INSERT INTO plch_employees
- VALUES (200, 'Ellison', 1000000);
-
- INSERT INTO plch_employees
- VALUES (300, 'Gates', 1000000);
-
- COMMIT;
- END;
- /
点击(此处)折叠或打开
- DECLARE
- TYPE pls_integer_t IS TABLE OF PLS_INTEGER
- INDEX BY PLS_INTEGER;
-
- l_ids pls_integer_t;
- l_indexes pls_integer_t;
- l_salary NUMBER;
- BEGIN
- l_ids (1) := 100;
- l_ids (2) := 200;
- l_ids (3) := 300;
- --
- l_indexes (1) := 1;
- l_indexes (2) := 3;
-
- FORALL indx IN VALUES OF l_indexes
- UPDATE plch_employees
- SET salary = salary * 2
- WHERE employee_id = l_ids (indx);
-
- SELECT SUM (salary) INTO l_salary FROM plch_employees;
- DBMS_OUTPUT.put_line (l_salary);
- END;
- /
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30260000/viewspace-1819687/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30260000/viewspace-1819687/