【发布时间】:2019-01-04 00:02:45
【问题描述】:
也许你知道问题出在哪里。
我有 3 种类型:
create or replace type t_money as object (
val number(14,2)
,cur varchar2(3 CHAR)
);
/
create or replace type t_wallet as object (
name varchar2(50 CHAR)
,amount t_money
);
/
create or replace type t_wallets is table of t_wallet;
/
我需要使用批量收集从游标填充嵌套表:
declare
walletCollection t_wallets;
cursor walletCursor is
select 'some name' as name
,t_money(99, 'EUR') as amount
from dual;
begin
open walletCursor;
fetch walletCursor bulk collect into walletCollection;
close walletCursor;
end;
Aaaaaaand ...它不起作用。我收到此错误:
ORA-06550: line 9, column 40: PLS-00386: type mismatch found at 'WALLETCOLLECTION' between FETCH cursor and INTO variables
我知道我可以使用:
type walletRecords is table of walletCursor%ROWTYPE;
walletCollection walletRecords;
但在这种情况下我不能这样做,并且 walletCollection 必须是 t_wallets 的嵌套表。
如何做到这一点?哪里错了?
Oracle 实时脚本 https://livesql.oracle.com/apex/livesql/s/hr22zxdw7842um41u9ylnraz1
【问题讨论】:
标签: oracle plsql type-mismatch