您好,登錄后才能下訂單哦!
http://www.itpub.net/thread-1499223-15-1.html
150樓
我連接到HR用戶并運行了如下語句:
CREATE TABLE plch_parts ( partnum NUMBER , partname VARCHAR2 (50) ) / BEGIN INSERT INTO plch_parts VALUES (1, 'Chassis'); COMMIT; END; / CREATE OR REPLACE PACKAGE plch_pkg IS TYPE parts_t IS TABLE OF plch_parts%ROWTYPE INDEX BY PLS_INTEGER; PROCEDURE plch_show_parts (parts_in IN parts_t); END; / CREATE OR REPLACE PACKAGE BODY plch_pkg IS PROCEDURE plch_show_parts (parts_in IN parts_t) IS BEGIN FOR indx IN 1 .. parts_in.COUNT LOOP DBMS_OUTPUT.put_line (parts_in (indx).partname); END LOOP; END; END; / GRANT SELECT ON plch_parts TO scott / GRANT EXECUTE ON plch_pkg TO scott /
然后我又用SCOTT用戶連接并創建了這張表:
CREATE TABLE plch_parts ( partnum NUMBER , partname VARCHAR2 (50) ) / BEGIN INSERT INTO plch_parts VALUES (100, 'Wheel'); COMMIT; END; /
下列的哪些選項包含了下列語句塊的一個聲明部分,從而使得這個塊執行之后"Wheel"會被顯示出來?
BEGIN SELECT * BULK COLLECT INTO l_parts FROM plch_parts; hr.plch_pkg.plch_show_parts (l_parts); END;
(A)
DECLARE TYPE parts_t IS TABLE OF plch_parts%ROWTYPE INDEX BY PLS_INTEGER; l_parts parts_t;
SQL> DECLARE 2 TYPE parts_t IS TABLE OF plch_parts%ROWTYPE INDEX BY PLS_INTEGER; 3 4 l_parts parts_t; 5 6 BEGIN 7 SELECT * BULK COLLECT INTO l_parts FROM plch_parts; 8 9 yoga.plch_pkg.plch_show_parts(l_parts); 10 END; 11 / DECLARE TYPE parts_t IS TABLE OF plch_parts%ROWTYPE INDEX BY PLS_INTEGER; l_parts parts_t; BEGIN SELECT * BULK COLLECT INTO l_parts FROM plch_parts; yoga.plch_pkg.plch_show_parts(l_parts); END; ORA-06550: 第 9 行, 第 3 列: PLS-00306: 調用 'PLCH_SHOW_PARTS' 時參數個數或類型錯誤 ORA-06550: 第 9 行, 第 3 列: PL/SQL: Statement ignored SQL>
(B)
DECLARE TYPE parts_t IS TABLE OF hr.plch_parts%ROWTYPE INDEX BY PLS_INTEGER; l_parts parts_t;
SQL> DECLARE 2 TYPE parts_t IS TABLE OF yoga.plch_parts%ROWTYPE INDEX BY PLS_INTEGER; 3 4 l_parts parts_t; 5 6 BEGIN 7 SELECT * BULK COLLECT INTO l_parts FROM plch_parts; 8 9 yoga.plch_pkg.plch_show_parts(l_parts); 10 END; 11 / DECLARE TYPE parts_t IS TABLE OF yoga.plch_parts%ROWTYPE INDEX BY PLS_INTEGER; l_parts parts_t; BEGIN SELECT * BULK COLLECT INTO l_parts FROM plch_parts; yoga.plch_pkg.plch_show_parts(l_parts); END; ORA-06550: 第 9 行, 第 3 列: PLS-00306: 調用 'PLCH_SHOW_PARTS' 時參數個數或類型錯誤 ORA-06550: 第 9 行, 第 3 列: PL/SQL: Statement ignored SQL>
(C)
DECLARE l_parts hr.plch_pkg.parts_t;
SQL> DECLARE 2 l_parts yoga.plch_pkg.parts_t; 3 4 BEGIN 5 SELECT * BULK COLLECT INTO l_parts FROM plch_parts; 6 7 yoga.plch_pkg.plch_show_parts(l_parts); 8 END; 9 / Wheel PL/SQL procedure successfully completed SQL>
(D)
DECLARE SUBTYPE parts_t IS hr.plch_pkg.parts_t; l_parts parts_t;
SQL> DECLARE 2 SUBTYPE parts_t IS yoga.plch_pkg.parts_t; 3 l_parts parts_t; 4 5 BEGIN 6 SELECT * BULK COLLECT INTO l_parts FROM plch_parts; 7 8 yoga.plch_pkg.plch_show_parts(l_parts); 9 END; 10 / Wheel PL/SQL procedure successfully completed SQL>
實測用yoga代替hr,test代替scott
答案在158樓
2011-11-16 答案CD.
%ROWTYPE是一種記錄,如果你定義兩個結構一模一樣的記錄類型,它們仍然不能夠互換,會報類型不匹配的錯誤。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。