Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: how to cast dbms_output.chararr type to table
<streib_at_cs.indiana.edu> wrote in message
news:1146569932.861338.7480_at_i39g2000cwa.googlegroups.com...
> Is it possible?
>
> I tried:
>
>> create type o_line as object(line varchar2(255));
> 2 /
>
> Type created.
>
>> create type o_lines as table of o_line;
> 2 /
>
> Type created.
>
>> create table a1 (a varchar2(255));
>
> Table created.
>
> begin
> dbms_output.enable;
> dbms_output.put_line('Line 1');
> dbms_output.put_line('Line 2');
> dbms_output.put_line('Line 3');
> dbms_output.put_line('Line 4');
> dbms_output.put_line('Line 5');
> end;
> /
>
> PL/SQL procedure successfully completed.
>
> declare
> outlines DBMS_OUTPUT.CHARARR;
> numlines pls_integer := 100;
> begin
> dbms_output.get_lines(outlines, numlines);
> insert into a1 (a)
> select line from table(cast(outlines as o_lines));
> end;
> /
>
> ERROR at line 7:
> ORA-06550: line 7, column 33:
> PLS-00382: expression is of wrong type
This is not possible with PL/SQL collections. However, you can
declare
outlines DBMS_OUTPUT.CHARARR;
numlines pls_integer := 100;
begin
dbms_output.get_lines(outlines, numlines); FORALL i IN outlines.FIRST..outlines.LAST -- note: no LOOP here
insert into a1 (a) VALUES(outlines(i));
end;
/
-- Vladimir M. Zakharychev N-Networks, makers of Dynamic PSP(tm) http://www.dynamicpsp.comReceived on Tue May 02 2006 - 07:34:02 CDT