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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Trigger to Combine Two Columns

Re: Trigger to Combine Two Columns

From: <alexman_at_icis-corp.com>
Date: Fri, 23 Apr 1999 18:27:54 GMT
Message-ID: <7fqe34$apt$1@nnrp1.dejanews.com>


In article <7fq7uu$4u5$1_at_nnrp1.dejanews.com>,   shieldsora_at_my-dejanews.com wrote:
> I have a table that has the following fields:
>
> group varchar2(25)primary
> group_num varchar2(5)
> group_name varchar2(20)
>
> I would like to set up a trigger so that the end user only has to enter the
> group_num and group_name and the trigger will combine the two fields seperated
> by a '.' to form the primary key.
>
> Could anyone give me some insight as to how I would formulate a trigger to
> combine these two imputs the way I desire?
>
> Thanks in advance,
>
> Mike
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

You must create a before trigger for each row ...(must fire before constraint validation of primary key field)

CREATE OR REPLACE TRIGGER fred BEFORE INSERT OR UPDATE  ON tablename FOR EACH ROW
BEGIN
     :new.group := :new.group_num || '.' || :new.group_name; END;
/
>

-----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own Received on Fri Apr 23 1999 - 13:27:54 CDT

Original text of this message

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