Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Question
Natter wrote:
>
> Does anybody know the answer to this or can
> you tell me where I can post this message?
> Thanks
>
> Here is the create code:
>
> create table bob(
> comp# number(5),
> c_name varchar2(25),
> c_address varchar2(50),
> c_city varchar2(15),
> c_zip number(5),
> constraint comp#_pk primary key (comp#));
>
> I want to add a secondary key that automatically uses
> the first 4 letters of the c_name and all 5 numbers of
> the c_zip fields. They need to be concatenated together.
>
> ex. c_name = HEWLETT PACKARD c_zip = 95688
> The secondary key called key would be HEWL95688
> This would be done automatically by the code.
>
> Is it possible??? I think it is I just don't know how to do it.
>
> tn
> natter_at_ecst.csuchico.edu
what you need to do is to create a trigger for that table. step 1.
add that colume to the table
step 2.
create the trigger before insert to populate that colume
hope this helps.
-- John Chan Manager, Data Services RTE Asset Management (aka. Rightime Econometrics, Inc.) 1095 Rydal Rd. Rydal, PA 19046-1711 215-572-7288 (Voice) 215-572-6254 (Fax) Internet address: john_at_rte-asset.comReceived on Tue Apr 22 1997 - 00:00:00 CDT