2016-02-05 80 views
0

是否可以将某些数据选择到用户定义的集合中?我创建了与查询返回相同的记录结构,然后尝试将数据选择到我的表中。Oracle - 选择(复杂查询)到用户定义的集合中

procedure MY_PROC(md number, pPERIOD date) is 
TYPE MainRecType IS RECORD (
    addr varchar2(100), 
    custom x_custom_table.custom%type,  
    id_cn number, 
    iddb_cn number 
); 
TYPE MainTable IS TABLE OF MainRecType 
    INDEX BY BINARY_INTEGER; 

begin 

    select * bulk collect into MainTable from //ERROR! 
    (
    select a.address addr, x.custom custom, b.id id_cn, b.id_db iddb_cn 
    from AddressTable a, x_custom_table x, BuildTable b 
    where a.id_build=b.id and a.id_x=x.id and b.period=pPeriod and b.md=md 
);  

end; 

它说PLS-00321: expression 'MainTable' is inappropriate as the left hand side。如果可能的话,我做错了什么?

回答

0

MainTable是一个集合类型。您将需要声明集合类型来获取数据的实例为

当然,我相信,在您的实际代码,一旦你填充它,你会做一些事情的集合。

+0

我无法想象它是如此愚蠢的错误!谢谢。 – Nolesh