Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: how to cast dbms_output.chararr type to table

Re: how to cast dbms_output.chararr type to table

From: Vladimir M. Zakharychev <bob--nospam--_at_dynamicpsp.com>
Date: Tue, 2 May 2006 16:34:02 +0400
Message-ID: <e37jjr$25g2$1@hypnos.nordnet.ru>

<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.com 
Received on Tue May 02 2006 - 07:34:02 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US