CREATE MATERIALIZED VIEW ORDERS_MV
BUILD IMMEDIATE
REFRESH COMPLETE ON DEMAND AS
SELECT * FROM ORDERS;
---------------------------------------
CREATE OR REPLACE TRIGGER update_ship_receive
INSTEAD OF INSERT ON ORDERS_MV
FOR EACH ROW
BEGIN
UPDATE ORDERS SET EXPECTED_SHIP_DATE = ORDER_DATE+5;
UPDATE ORDERS SET EXPECTED_RECEIVE_DATE = SHIP_DATE+1
WHERE SHIPPING_METHOD = '1 DAY';
UPDATE ORDERS SET EXPECTED_RECEIVE_DATE = SHIP_DATE+2
WHERE SHIPPING_METHOD = '2 DAY';
UPDATE ORDERS SET EXPECTED_RECEIVE_DATE = SHIP_DATE+5
WHERE SHIPPING_METHOD = 'GROUND';
END;
/
Why does this trigger fail? It says invalid identifier
1.1k Views Asked by indolent At
3
There are 3 best solutions below
0

Not an Oracle guy, but shouldn't you use
:OLD.SHIP_DATE
or
:NEW.SHIP_DATE
and
:OLD.ORDER_DATE
or
:NEW.ORDER_DATE
refer: Oracle's trigger doc
Oracle can see your table structures. We can't. I'm betting Oracle sees the problem in your code.
It should point to the first line with the error. If not, select * from user_errors;
Maybe your ORDERS table doesn't have SHIP_DATE (since the first statement talks about EXPECTED_SHIP_DATE).