使用PL / SQL中的Bulk collect进入表对象类型

时间:2016-02-19 01:00:12

标签: sql oracle stored-procedures plsql

有人可以告诉我为什么在编译程序时出现PL / SQL错误:

  

错误(11,23):PLS-00403:表达式' USER_DETAILS_LIST'不能用作SELECT / FETCH语句的INTO目标。

以下是对象和程序:

CREATE OR REPLACE TYPE  USERID IS OBJECT
(
 USERID             VARCHAR2(50)
);

CREATE OR REPLACE TYPE  USERID_LIST AS TABLE OF  USERID;

CREATE OR REPLACE TYPE  USER_DETAILS IS OBJECT
(
 USERID             VARCHAR2(50),
 ORGANIZATION       VARCHAR2(200),
 EMAIL              VARCHAR2(200),
 FIRSTNAME          VARCHAR2(200),
 LASTNAME           VARCHAR2(200),
 FULLNAME           VARCHAR2(200)
);

CREATE OR REPLACE TYPE  USER_DETAILS_LIST AS TABLE OF  USER_DETAILS;

CREATE OR REPLACE PROCEDURE GET_USER_DETAILS_FOR_NOTIF(USERID_LIST IN USERID_LIST,
    USER_DETAILS_LIST IN  USER_DETAILS_LIST) IS

BEGIN
    SELECT  USER_DETAILS(USER_ID,
                         ORGANIZATION,
                         EMAIL,
                         FIRSTNAME,
                         LASTNAME,
                         FULLNAME)
            BULK COLLECT INTO USER_DETAILS_LIST
            FROM    USERS_TBL
            WHERE   USER_ID IN (SELECT USERID
                                  FROM TABLE( USERID_LIST));
END;

1 个答案:

答案 0 :(得分:0)

在程序签名中,USER_DETAILS_LIST需要指定为IN OUT而不是IN,因为:

CREATE OR REPLACE PROCEDURE GET_USER_DETAILS_FOR_NOTIF(USERID_LIST IN USERID_LIST,
    USER_DETAILS_LIST IN OUT USER_DETAILS_LIST)
    ...