Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:03:48+00:00 2026-05-27T12:03:48+00:00

EDIT: Please disregard, I fixed it by disabling and then re-enabling the trigger. I

  • 0

EDIT: Please disregard, I fixed it by disabling and then re-enabling the trigger. I don’t quite know why or how this fixed it as I never disabled it in the first place. Thanks all.

This trigger is meant to control the order of order_status values. So an order with a status “Dispatched” cannot become “Ready for Dispatch”, or an order with the value “Delivered” cannot become “Dispatched” etc.

It used to work fine, but today I converted the order table into an object table (well, dropped it and made a type etc) and since then it’s not worked. Constraints work fine, just not this trigger. It compiles without an issue but it simply never catches the fault. If anyone could help me here I’d appreciate it.

CREATE OR REPLACE TRIGGER Check_Order_Status  
BEFORE INSERT OR UPDATE ON Customer_Order 
for each row

BEGIN 

IF (:new.order_status='Processed' AND :old.order_status='Delivered'
 OR :new.order_status='Processed' AND :old.order_status='Dispatched' 
 OR :new.order_status='Dispatched' AND :old.order_status='Delivered' 
 OR :new.order_status='Delayed' AND :old.order_status='Delivered' 
 OR  :new.order_status='Ready for Dispatch' AND :old.order_status='Dispatched' 
 OR :new.order_status='Ready for Dispatch' AND :old.order_status='Delivered' 
 OR :new.order_status='Dispatched' AND :old.order_status IS NULL ) 
then  
 RAISE_APPLICATION_ERROR(-20103, 'There has been an issue with the order update or insert.');
ELSE
 dbms_output.put('Order Status of ' || :old.order_no || ' is now ' || :new.order_status);
END IF;

END; 
. 
run
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:03:49+00:00Added an answer on May 27, 2026 at 12:03 pm

    Here is a minimalistic implementation of your scenario:

    SQL> create or replace type order_rec as object
        (order_no number
         , order_status varchar2(30)
         , input_date date
         , ship_date date )
    /
      2    3    4    5    6
    Type created.
    
    SQL>
    SQL> create table Customer_Order of order_rec
    /
    
      2
    Table created.
    
    SQL>
    

    and your trigger compiles. So far, so good.

    SQL> CREATE OR REPLACE TRIGGER Check_Order_Status
    BEFORE INSERT OR UPDATE ON Customer_Order
    for each row
    
    BEGIN
    
    IF (:new.order_status='Processed' AND :old.order_status='Delivered'
     OR :new.order_status='Processed' AND :old.order_status='Dispatched'
     OR :new.order_status='Dispatched' AND :old.order_status='Delivered'
     OR :new.order_status='Delayed' AND :old.order_status='Delivered'
     OR  :new.order_status='Ready for Dispatch' AND :old.order_status='Dispatched'
     OR :new.order_status='Ready for Dispatch' AND :old.order_status='Delivered'
     OR :new.order_status='Dispatched' AND :old.order_status IS NULL )
    then
     RAISE_APPLICATION_ERROR(-20103, 'There has been an issue with the order update or insert.');
    ELSE
     dbms_output.put('Order Status of ' || :old.order_no || ' is now ' || :new.order_status);
    END IF;
    
    END;   2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20
     21  /
    
    Trigger created.
    
    SQL>
    

    Let’s create a row:

    SQL> set serveroutput on
    
    insert into customer_order values ( order_rec (1, 'New', sysdate, null))
    /
    
    SQL> SQL>   2
    1 row created.
    
    SQL>
    
    update customer_order
    set order_status = 'Dispatched'
    where order_no = 1
    /
    SQL>   2    3    4
    1 row updated.
    
    SQL>
    

    Hmmm, it’s a bit silent. Let’s poke it:

    SQL> update customer_order
    set order_status = 'Processed'
    where order_no = 1
    /
      2    3    4  update customer_order
           *
    ERROR at line 1:
    ORA-20103: There has been an issue with the order update or insert.
    ORA-06512: at "APC.CHECK_ORDER_STATUS", line 11
    ORA-04088: error during execution of trigger 'APC.CHECK_ORDER_STATUS'
    
    
    SQL>
    

    Your trigger works, for me at least. So why aren’t we seeing the DBMS_OUTPUT.PUT_LINE() calls ? Don’t know, but I would guess it’s probably a bug.


    Incidentally, you should extract that logic from the trigger and put it in a member function on the object. An object is a set of data and a set of related behaviours. Status validation is definitely a behaviour, so it is even more wrong to have such a trigger on an object table than it was on a normal table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: Please disregard this quesion. This was a goof on my end: I was
I'm not sure what kind of terminology to use in this so please edit
Please let me know if you have any idea about it. Thanks EDIT What
EDIT: Please ignore this question - I've managed to solve it in a way
UPDATE: This question is outdated, please disregard So.. my idea is to load a
EDIT: Please note that this question is OUTDATED; RVM got way easier to use
Please note the Edit below for a lot more information, and a possible solution
**EDIT: There are several options below that would work. Please vote/comment according to your
Why new()/delete() is slower than malloc()/free()? EDIT: Thanks for the answers so far. Please
Edit: This question was written in 2008, which was like 3 internet ages ago.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.