Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 240 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187.1K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 443 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Updating section of the trigger not working

I am using a trigger in Apex. Can someone tell me what is wrong in this trigger statement. The Inserting and Deleting sections work as expected in the case statement.
But when it comes to updating it is not executing based on the field condition. it is always executing first one in updating section Please help
**********************************************************************
create or replace TRIGGER AIU_BASE_ACTIONS
AFTER
INSERT OR
UPDATE OF STATUS,PRIORITY OR
DELETE
ON BASE_TANKS FOR EACH ROW
BEGIN
CASE
WHEN INSERTING THEN
PL/SQL Statement
WHEN UPDATING('STATUS') THEN -- This part is executing always even if I update the priority field
PL/SQL Statement
WHEN UPDATING('PRIORITY') THEN
PL/SQL Statement
WHEN DELETING THEN
PL/SQL Statement
END CASE;
END;
*************************************************************************
Answers
-
Hi gkthomas,
I have tried the code given below and this is working for me.
modified your code according to my testing, try this
create or replace TRIGGER AIU_BASE_ACTIONS AFTER INSERT OR UPDATE OF STATUS,PRIORITY OR DELETE ON BASE_TANKS FOR EACH ROW BEGIN CASE WHEN INSERTING THEN PL/SQL Statement WHEN UPDATING THEN IF :New.STATUS != :Old.STATUS THEN PL/SQL Statement ELSIF :New.PRIORITY != :Old.PRIORITY THEN PL/SQL Statement END IF; WHEN DELETING THEN PL/SQL Statement END CASE; END;
Hope this helps you,
Regards,
Jitendra
-
gkthomas wrote: I am using a trigger in Apex. Can someone tell me what is wrong in this trigger statement. The Inserting and Deleting sections work as expected in the case statement. But when it comes to updating it is not executing based on the field condition. it is always executing first one in updating section Please help ********************************************************************** create or replace TRIGGER AIU_BASE_ACTIONS
AFTER
INSERT OR
UPDATE OF STATUS,PRIORITY OR
DELETE
ON BASE_TANKS FOR EACH ROW BEGIN
CASE
WHEN INSERTING THEN
PL/SQL Statement WHEN UPDATING('STATUS') THEN -- This part is executing always even if I update the priority field PL/SQL Statement WHEN UPDATING('PRIORITY') THEN PL/SQL Statement WHEN DELETING THEN PL/SQL Statement END CASE;
END; *************************************************************************What DML code is being executed by APEX to cause the trigger to fire?
Only one branch of the case statement can be executed, which will always be the first matching condition. If your page is using a standard wizard-generated APEX ARP or MRU process then all of the columns linked to items in the page will be updated, including both STATUS and PRIORITY. Since the STATUS clause appears first, that is the only logic that will ever be executed following an update.
If you want both the STATUS and PRIORITY logic to be executed on an update involving both columns, change the code to:
create or replace trigger aiu_base_actions after insert or update of status, priority or delete on base_tanks for each row begin case when inserting then pl/sql statement when updating then if updating('STATUS') then pl/sql statement end if; if updating('PRIORITY') then pl/sql statement end if; when deleting then pl/sql statement end case; end;
If you have other requirements, then specify them clearly: how to get answers from forum
-
Jitendra wrote: I have tried the code given below and this is working for me. modified your code according to my testing, try this
- create or replace TRIGGER AIU_BASE_ACTIONS
- AFTER
- INSERT OR
- UPDATE OF STATUS,PRIORITY OR
- DELETE
- ON BASE_TANKS
- FOR EACH ROW
- BEGIN
- CASE
- WHEN INSERTING THEN
- PL/SQL Statement
- WHEN UPDATING THEN
- IF :New.STATUS != :Old.STATUS THEN
- PL/SQL Statement
- ELSIF :New.PRIORITY != :Old.PRIORITY THEN
- PL/SQL Statement
- END IF;
- WHEN DELETING THEN
- PL/SQL Statement
- END CASE;
- END;
create or replace TRIGGER AIU_BASE_ACTIONS AFTER INSERT OR UPDATE OF STATUS,PRIORITY OR DELETE ON BASE_TANKS FOR EACH ROW BEGIN CASE WHEN INSERTING THEN PL/SQL Statement WHEN UPDATING THEN IF :New.STATUS != :Old.STATUS THEN PL/SQL Statement ELSIF :New.PRIORITY != :Old.PRIORITY THEN PL/SQL Statement END IF; WHEN DELETING THEN PL/SQL Statement END CASE; END;
That does not work in all cases. If both STATUS and PRIORITY are updated then the PRIORITY branch will not be executed.