SQL Statement Producing Error in PL/SQL Casting Multiset to Object Type
I'm trying to improve some data processing by manipulating some subset data via object types.
I initially ran this SQL statement, inserting into a table, which runs fine:
insert into readflag_test
select
mpan_core,
CASE
WHEN Sumcount > 0 then 'Val Rd'
ELSE 'Read' END as Readflag
from
(
select
mpan_core,
sum(Readflag) Sumcount
from(
select distinct
a.msy_mpan_core as mpan_core,
CASE
WHEN a.effective_from_date > b.effective_from_date and b.last_read_date > b.effective_from_date then '1'
WHEN a.effective_from_date <= b.effective_from_date and b.last_read_date > b.effective_from_date then '0'
ELSE null END as Readflag
from
reading_sets a,
(select mpan_core, effective_from_date, last_read_date from oracle81.noreads_report_safe) b
where
a.msy_mpan_core||null = b.mpan_core and
reading_completeness!='E' and
a.reading_status in ('0','1') and
a.reading_state||null='4')
where Readflag is not null
group by mpan_core);
I then attempted to run it as a component in a PL/SQL routine as follows:
select cast(multiset(
select
mpan_core,
CASE
WHEN Sumcount > 0 then 'Val Rd'
ELSE 'Read' END as Readflag
from
(select
mpan_core,
sum(Readflag) Sumcount
from
(select distinct
a.msy_mpan_core as mpan_core,
CASE
WHEN a.effective_from_date > b.effective_from_date and b.last_read_date > b.effective_from_date then '1'
WHEN a.effective_from_date <= b.effective_from_date and b.last_read_date > b.effective_from_date then '0'
ELSE null END as Readflag
from
reading_sets a,
(select mpan_core, effective_from_date, last_read_date from oracle81.noreads_report_safe) b
where
a.msy_mpan_core||null = b.mpan_core and
reading_completeness!='E' and
a.reading_status in ('0','1') and
a.reading_state||null='4')
where Readflag is not null
group by mpan_core))
as noreads_readflag_table_type)
into v_noreads_readflag_table
from dual;
This is throwing out some error message as follows, and I don't seem to be able to deduce where it is!
Bookmarks