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

Home -> Community -> Usenet -> c.d.o.tools -> Re: need help

Re: need help

From: Michel Cadot <micadot_at_netcourrier.com>
Date: Wed, 28 Mar 2001 09:41:36 +0200
Message-ID: <99s4jh$k4n$1@s1.read.news.oleane.net>

"C.K." <cklok2000_at_sinaman.com> a écrit dans le message news: 99rm67$q7i$1_at_charm.magnus.acs.ohio-state.edu...
>
> i'm trying to make a trigger which will send some records to table B
> after/before insert to table A
> however, one of the field of table A must be a "LONG" datatype, while that
> field in table B must be a "VARCHAR2" datatype for some reason.
> can you help me out of how to convert it or whatever way i can archieve
> that goal?
> i will appreicate it
>
>
>
>

You can split your LONG in small pieces to record it in the VARCHAR2. Something like:

create trigger ...

   longValue varchar2(32767);
   colLength integer := <varchar2 col size>;    i integer := 1;
   lg integer;
   pieceNb integer := 0;
begin

   longValue := :new.<long col>;
   lg := length(longValue);
   while ( i <= lg ) loop

      insert into <tableB> (<varchar2 col>)
         values (pieceNb, substr(longValue,i,colLength);
      pieceNb := pieceNb + 1;
      i := i + lg;

   end loop;
end;
--
Hope this helps
Michel
Received on Wed Mar 28 2001 - 01:41:36 CST

Original text of this message

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