我在 oracle 中为一个过程创建了一个类型数据。
程序:
create or replace TYPE ROW_USER as object
(
ID NUMBER(4),
ROLES_ID NUMBER(1),
FIRST_NAME VARCHAR2(60 BYTE),
SECOND_NAME VARCHAR2(60 BYTE),
FIRST_LAST_NAME VARCHAR2(60 BYTE),
SECOND_LAST_NAME VARCHAR2(60 BYTE),
CC NUMBER(10,0),
EMAIL VARCHAR2(60 BYTE)
);
和:
create or replace type NESTED_ROW_USER as table of ROW_USER;
当我在匿名块中使用这种类型的数据并且它起作用时。
set serveroutput on;
DECLARE
ROWUSR NESTED_ROW_USER;
BEGIN
select cast( multiset(select id, ROLES_ID, FIRST_NAME, SEGUNDO_NOMBRE,
FIRST_LAST_NAME, SECOND_LAST_NAME, CC, EMAIL from USERS where id = 1) as
NESTED_ROW_USER)
into ROWUSR
from users;
DBMS_OUTPUT.PUT_LINE(ROWUSR(1).id||','||ROWUSR(1).ROLES_ID||','||
ROWUSR(1).FIRST_NAME);
END;
块结果:
Process PL/SQL exited successfully.
1,1,DIEGO
但是当我在存储过程中使用它来返回它时,我得到一个错误。
程序:
create or replace PROCEDURE outnested(ROWUSR OUT NESTED_ROW_USR)
AS
BEGIN
select cast( multiset(select id, ROLES_ID, FIRST_NAME, SECOND_NAME,
FIRST_LAST_NAME, SECOND_LAST_NAME, CC, EMAIL from USERS where id = 1) as
NESTED_ROW_USER)
into ROWUSR
from users;
END;
错误:
ORA-06550: line 5, column 16:
PLS-00302: component 'NESTED_ROW_USER' must be declared
ORA-06550: line 5, column 11:
PL/SQL: Item ignored
ORA-06550: line 14, column 16:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 10, column 3:
PL/SQL: Statement ignored
为什么它不返回值?