Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Pl/Sql Casting Objects: error using the TABLE operator
Hi!
I'm trying to use the TABLE operator in a pl/sql block with a pl/sql nested table of objects.
I've succeeded using CASTING, TABLE and MULTISET with a table of dates.
Giving these types and table definitions:
/* creation of a table */
whenever sqlerror continue;
drop table my_table
/
create table my_table (col1 date, col2 date)
/
insert into my_table values (to_date('1900-01-01', 'yyyy-mm-dd'),
to_date('1900-01-01', 'yyyy-mm-dd'));
insert into my_table values (to_date('1900-01-02', 'yyyy-mm-dd'),
to_date('1900-01-02', 'yyyy-mm-dd'));
/* creation of types */
drop type my_type_table_date
/
drop type my_type_table_object
/
drop type my_type_object
/
create type my_type_table_date is table of date
/
create type my_type_object is object(ddb date, ddf date)
/
create type my_type_table_object is table of my_type_object
/
I would appreciate a lot if someone could tell me why (oh why) this works:
declare
vtbl my_type_table_date;
begin
SELECT CAST(MULTISET(select col1
from my_table ) AS my_type_table_date )
for vrow in (select column_value as col1
from table(cast(vtbl as my_type_table_date ) ) ) loop dbms_output.put_line(to_char(vrow.col1, 'yyyy-mm-dd'));end loop;
but not this:
declare
vtbl my_type_table_object;
begin
SELECT CAST(MULTISET(select col1, col2
from my_table ) AS my_type_table_object )
for vrow in (select column_value as col1
from table(cast(vtbl as my_type_table_object ) ) ) loop dbms_output.put_line(to_char(vrow.col1, 'yyyy-mm-dd'));end loop;
Thanks in advance
Joe001 Received on Mon Jul 04 2005 - 13:53:46 CDT
![]() |
![]() |