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 4028966
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:17:11+00:00 2026-05-20T11:17:11+00:00

Possible Duplicate: Why does this trigger fail? It says invalid identifier. CREATE MATERIALIZED VIEW

  • 0

Possible Duplicate:
Why does this trigger fail? It says invalid identifier.

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;
/
  • 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-20T11:17:11+00:00Added an answer on May 20, 2026 at 11:17 am

    This doesn’t work because a materialized view is not a view it is a special kind of table: it has data, we can enforce constraints with it, etc.

    So having got that out of the way let’s look at your underlying process logic, which is confusing. You have a materialized view based on a table. Now you want to build a trigger which updates the base table whenever a row is inserted into the materialized view.

    1. Do you expect the materialized view to contain the changed data?

    2. Because of the way you have specified the SQL the trigger (if it could work) would update every row in the ORDERS table.

    3. Because the trigger is FOR EACH ROW refreshing the materialized view would update the entire ORDERS table multiple times, once for each row in the ORDERS table.

    4. INSTEAD OF triggers execute the code in the trigger body rather than (instead of) the action specified in the trigger header. So (if it could work) the trigger would update the ORDERS table and insert no rows into the materialized view.

    So I hope you can see that this error is preventing you from making a more serious architectural error. What you need to do is clarify your business process and then seek to express that in SQL. To my mind, the most appropriate solution would be a BEFORE UPDATE trigger on the ORDERS table. Something like this:

    CREATE OR REPLACE TRIGGER update_ship_receive
        BEFORE INSERT or UPDATE ON ORDERS
        FOR EACH ROW
    BEGIN
    
        if :new.EXPECTED_SHIP_DATE is null
        then
            :new.EXPECTED_SHIP_DATE = :new.ORDER_DATE+5;
        end if;
    
        if :new.EXPECTED_RECEIVE_DATE is null
        then 
            case :new.SHIPPING_METHOD
                when '1 DAY' then        
                   :new.EXPECTED_RECEIVE_DATE = :new.SHIP_DATE+1; 
                when '2 DAY' then        
                   :new.EXPECTED_RECEIVE_DATE = :new.SHIP_DATE+2;
                when 'GROUND' then        
                   :new.EXPECTED_RECEIVE_DATE = :new.SHIP_DATE+5; 
                else
                   null;
             end case;
        end if;
    END;
    /
    

    You then just have a simple materialized view with no associated processing to undertake when you refresh it. Obviously your actual business logic may dictate a different solution.

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

Sidebar

Related Questions

Possible Duplicate: How does this work? Weird Towers of Hanoi Solution While surfing Google,
Possible Duplicate: What does this C++ code mean? I'm trying to map a C
Possible Duplicate: Reference - What does this symbol mean in PHP? Is there any
Possible Duplicate: C programming, why does this large array declaration produce a segmentation fault?
Possible Duplicate: Why does this conversion doesn't work? Hi, i discovered a strange behaviour
Possible Duplicate: Reference - What does this symbol mean in PHP? I was wondering
Possible Duplicate: or is not valid C++ : why does this code compile ?
Possible Duplicate: what does #someDiv mean? i am doing this: onmouseover=evt.target.setAttribute('opacity', '0.5'); $('#someDiv').show(); onmouseout=evt.target.setAttribute('opacity','1)');
Possible Duplicate: What does this JavaScript/jQuery syntax mean? I specifically mean when you do
Possible Duplicate: What does this CSS shorthand font syntax mean? I saw many people

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.