0

I have created a trigger which inserts City as Others for all the data inserted with City name OTHERS

But it updates as null for text other than OTHERS. So I want to add IF condition for the same. Below is my trigger.

create or replace TRIGGER TGR_UPD_OTHERS_TVIPL
   BEFORE INSERT OR UPDATE ON IPCOLO_IPFEE_CALC_MST
FOR EACH ROW
 BEGIN
     new.CITY := case :NEW.CITY
                     when 'OTHERS' THEN 'Others'
                     end;
END;

1 Answer 1

1

That's because you didn't say what to do "else":

:new.city := case when :new.city = 'OTHERS' then 'Others'
                  else :new.city
             end;
Sign up to request clarification or add additional context in comments.

7 Comments

In front end; it is responsible for displaying values. Somewhere is something set to display 0 as "undefined". Could even be in front end's query (using CASE or DECODE).
Should work for any table (unless there's something that prevents it to; perhaps another trigger?).
If you can afford dropping it, do it and you'll see whether there's any difference. On the other hand, did you debug it first? I mean, maybe there's some (not that) obvious reason which prevents trigger from working.
I cant see any reason for the same. yes i can afford deleting the table as its on dev env.
What is "it"? Select statement you ran in e.g. SQL Developer, or your front-end application?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.