|
2012-2-15 答案 C.
A: varray不能用DELETE方法。你只能用TRIM方法从尾部删除数组元素。
B: 这是SQL语法,不能用于数组。错误:ORA-00903: invalid table name
C: 正确的TRIM用法。
D: 只是把数组元素赋值为NULL, 还在数组里面。
==============================================
2012-2-16 FORALL中的VALUES OF子句
作者:Steven Feuerstein
难度:高
我创建了如下的表并填入数据:
CREATE TABLE plch_employees
(
employee_id INTEGER
, last_name VARCHAR2 (100)
, salary NUMBER
)
/
BEGIN
INSERT INTO plch_employees VALUES (100, 'Picasso', 1000000);
INSERT INTO plch_employees VALUES (200, 'Mondrian', 1000000);
INSERT INTO plch_employees VALUES (300, 'O''Keefe', 1000000);
COMMIT;
END;
/
然后我写了下面这个不完整的代码块:
DECLARE
/*DECLARE*/
l_salary NUMBER;
BEGIN
/*SETUP*/
FORALL indx IN VALUES OF l_indexes
UPDATE plch_employees
SET salary = salary * 2
WHERE employee_id = l_ids (indx);
SELECT SUM (salary)/1000000 INTO l_salary FROM plch_employees;
DBMS_OUTPUT.put_line (l_salary);
END;
/
哪些选项可用来替代上面的两个注释,从而使得这个块执行后会显示 "5"?
(A)
用如下取代 /*DECLARE*/:
TYPE pls_integer_t IS TABLE OF PLS_INTEGER
INDEX BY PLS_INTEGER;
l_ids pls_integer_t;
l_indexes pls_integer_t;
用如下取代 /*SETUP*/:
l_ids (1) := 100;
l_ids (2) := 200;
l_ids (3) := 300;
l_indexes (200) := 2;
l_indexes (300) := 3;
(B)
用如下取代 /*DECLARE*/:
TYPE pls_integer_t IS TABLE OF PLS_INTEGER
INDEX BY PLS_INTEGER;
l_ids pls_integer_t;
l_indexes pls_integer_t;
用如下取代 /*SETUP*/:
l_ids (1) := 100;
l_ids (2) := 200;
l_ids (3) := 300;
l_indexes (1) := 100;
l_indexes (3) := 300;
(C)
用如下取代 /*DECLARE*/:
TYPE pls_integer_t IS TABLE OF PLS_INTEGER
INDEX BY PLS_INTEGER;
l_ids pls_integer_t;
l_indexes pls_integer_t;
用如下取代 /*SETUP*/:
l_ids (1) := 100;
l_ids (2) := 200;
l_ids (3) := 300;
l_indexes (200) := 2;
l_indexes (300) := 3;
l_indexes (400) := 3;
(D)
用如下取代 /*DECLARE*/:
TYPE pls_integer_t IS TABLE OF PLS_INTEGER
INDEX BY PLS_INTEGER;
l_ids pls_integer_t;
l_indexes pls_integer_t;
用如下取代 /*SETUP*/:
l_ids (1) := 100;
l_ids (2) := 200;
l_ids (3) := 300;
l_indexes (1) := 1;
l_indexes (2) := 3;
(E)
用如下取代 /*DECLARE*/:
TYPE numbers_t IS TABLE OF NUMBER;
l_ids numbers_t := numbers_t (100, 200, 300);
l_indexes numbers_t := numbers_t (1, 3);
把 /*SETUP*/ 用空白取代。
|
|