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: Autopopulation by concatenation

Re: Autopopulation by concatenation

From: Gert Rijs <gem_at_wirehub.nl>
Date: 1997/02/11
Message-ID: <01bc1842$980b0b20$515fa5c2@gertrijs>#1/1

Coburn Watson <cpw_at_slip.net> wrote in article <32FFC8F9.6BC4_at_slip.net>...
> I have a relatively basic table which, when insertions are made, I would
> like the last field (trackid) to be generated by concatenating the
> values of the first two fields (num1 & place1). For example, if I
> insert a row into this table with the data (num1, place1)values (4,
> paris), then I would like my trackid field to be "4paris". I attempted
> to perform this action with an AFTER INSERT trigger, but I get the
> "mutating" table error. I take this is since the data which the trigger
> is relying on has just been inserted and is unavaible for selection
> (?!?). Any help would be appreciated.
>
> Coburn Watson
> Information Systems Support - Research
> Scios, Inc.
> cpw_at_slip.net
>

How about a BEFORE trigger like
create or replace trigger bef_tab

   before insert or update on tab
   for each row
begin

   :new.trackid := to_char(:new.num1)||:new.place1; end;
except for maybe some typo's this should do the trick (perhaps you should check for NULLs).

-- 
At Home: gem_at_wirehub.nl
At Work: gert.rijs_at_corp.ah.nl
Received on Tue Feb 11 1997 - 00:00:00 CST

Original text of this message

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