Re: sql*Loader & DB trigger problem.

From: Paul Zerhusen <paul_at_biometrie.uni-koeln.de>
Date: 1997/02/21
Message-ID: <330DE12A.4D23_at_biometrie.uni-koeln.de>#1/1


engsys_at_merlion.singnet.com.sg wrote:
>
> Hello there,
>
> Let me explain my problem,
> I have a table which i am loading from a flat file.
> there is a field to be populated based on the values of another field
> being loaded. i thought i can use db trigger.
>
> so i have created a trigger
>
> create or replace trigger load_tab before insert on my_table
> for each row
> begin
> if old.field1 = 'VALUE1' THEN
> new.field2 := 'ONEVALUE';
> else
> new.field2 := 'OTHERS';
> end if;
> end;
>
> but unfortunately, i see the field2 always has OTHERS, irrespective of
> field1. Can someone help me as where I am doing the mistake.
>
> Thanks in advance.
>
> with regards,
> prasad.

In my opinion, old.field1 does not yet exist during the execution of a trigger 'before insert '. So a comparison will always lead to nothing. Comparing with new.field1 should work.

good luck

Paul Received on Fri Feb 21 1997 - 00:00:00 CET

Original text of this message