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: <jeff109_at_NOSPAM.netscape.net>
Date: Fri, 23 Apr 1999 19:14:51 GMT
Message-ID: <3720c2df.21787428@news>


Hi, Mike.

        You could set up a row-level trigger before Insert and before Update of group_num, group_name that would set

        :new.group = :new.group_num||'.'||:new.group_name;

I would recommend that you implement some error trapping that first checks to see if this would result in a constraint violation due to duplicate primary keys, which is not allowed. You should probably consider the repercussions of allowing your users to change a primary key in the first place. You may want to opt for making this a candidate key and just using a sequence for the primary key. Your group field would actually need a length of 26, one extra for the period.

I hope this helps. Please feel free to e-mail me if you have any more questions on this (remove the NOSPAM).

Good luck,
-Jeff Guttadauro

On Fri, 23 Apr 1999 16:43:11 GMT, 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
Received on Fri Apr 23 1999 - 14:14:51 CDT

Original text of this message

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