Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Trigger to Combine Two Columns
MIke wrote
> 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.
create or replace trigger biu_my_table
before insert or update on my_table for each row begin :new.group := :new.group_num || '.' || :new.group_name;end biu_my_table;
However, you could also simply use both columns as the primary key:
create table my_table
( group_num varchar2(5) , group_name varchar2(20) , .... , primary key (group_num, group_name) );
Arjan. Received on Fri Apr 23 1999 - 13:20:04 CDT
![]() |
![]() |