oracle报错00801,PLS-00801: Type xxxxxx has no MAP method 这到底是啥啊……

博主在Oracle数据库中将低效视图改为带日期参数的函数,但在尝试扩展功能以支持日期区间查询时遇到PLS-00801错误。问题出现在使用`multiset union`操作时。代码在Oracle11g上运行正常,但在Oracle10g上报错。尽管进行了测试,该错误仍然神秘且难以理解。可能的原因包括版本差异或特定数据库设置问题。
摘要由CSDN通过智能技术生成

前段时间把一个查询效率很低的视图给改成了 带一个日期参数的函数,输入一个日期,返回相应的结果集。但是这样没能完整地复制视图原有的功能,比如给定一个日期区间的查询就做不到了。于是今天给扩充了一下,然后就遇到了这个该死的莫名其妙的PLS-00801.

代码呢是这样的:

create table stockstructure (

oc_date NUMBER(10) ,

exchange_type CHAR(4) ,

stock_code CHAR(12) ,

total_amount NUMBER(20,3),

turnover_amount NUMBER(20,3) ,

remark VARCHAR2(2000 )

);

create or replace type rec_stockstructure is OBJECT(

oc_date NUMBER(10 ) ,

exchange_type CHAR(4 ) ,

stock_code CHAR(12 ) ,

total_amount NUMBER(20 ,3),

turnover_amount NUMBER(20 ,3) ,

remark VARCHAR2(2000 )

);

create or replace type ty_stockstructure is table of rec_stockstructure;

create or replace function fn_get_stockstructure(

p_oc_date hstype.HsDate,

p_end_date hstype.hsdate default 0

)

return ty_stockstructure

is

tmp_stockstructure ty_stockstructure := ty_stockstructure();

rs_stockstructure ty_stockstructure := ty_stockstructure();

begin

if p_end_date = 0 then

select rec_stockstructure(p_oc_date,a.exchange_type,a.stock_code,a.total_amount,a.turnover_amount,a.remark)

bulk collect into rs_stockstructure

from stockstructure a

where (a.oc_date,a.exchange_type,a.stock_code) in

( select max (t.oc_date),t.exchange_type,t.stock_code from stockstructure t

where oc_date<=p_oc_date

group by t.exchange_type,t.stock_code

)

;

else

for xdate in 0..(to_date(p_end_date,'yyyymmdd' )-to_date(p_oc_date,'yyyymmdd')) loop

select rec_stockstructure(to_char(to_date(p_oc_date,'yyyymmdd' )+xdate,'yyyymmdd'),a.exchange_type,a.stock_code,a.total_amount,a.turnover_amount,a.remark)

bulk collect into tmp_stockstructure

from stockstructure a

where (a.oc_date,a.exchange_type,a.stock_code) in

( select max (t.oc_date),t.exchange_type,t.stock_code from stockstructure t

where oc_date<=to_char(to_date(p_oc_date,'yyyymmdd' )+xdate,'yyyymmdd')

group by t.exchange_type,t.stock_code

)

;

rs_stockstructure := rs_stockstructure multiset union tmp_stockstructure; --------------------- 报错位置

end loop ;

end if;

return rs_stockstructure;

end;

然后就在我标着的位置给抛出了一个错误。错误原文如此:

Error: PLS-00801: internal error [*** ASSERT at file pdw4.c, line 2079; Type 0x0x2b89f96a66e0 has no MAP method.;

于是我就纠结了,这到底说的是啥呢?这几个关键字我连搜索都没法搜。而且更纠结的是,在Oracle 11g 上不报错,在 Oracle 10g 上报错。那么是版本问题嘛?我查了下,10g multiset 的支持完全没问题啊。我又在报错的这个数据库上做了个这样的测试:

select * from table(

ty_stockstructure(rec_stockstructure(1234,'1','1234',1,1,'1'))

multiset union

ty_stockstructure(rec_stockstructure(2234,'2','2234',2,2,'2'))

)

结果也是好好的,完全符合预期。真是无厘头啊,这都什么情况啊……

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值