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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:15:09+00:00 2026-06-16T15:15:09+00:00

Friend, I have question about cascade trigger. I have 2 tables, table data that

  • 0

Friend, I have question about cascade trigger.
I have 2 tables, table data that has 3 attributes (id_data, sum, and id_tool), and table tool that has 3 attributes (id_tool, name, sum_total). table data and tool are joined using id_tool.

I want create trigger for update info sum_total. So , if I inserting on table data, sum_total on table tool where tool.id_tool = data.id_tool will updating too.

I create this trigger, but error ora-04090.

create or replace trigger aft_ins_tool
after insert on data
for each row
declare
v_stok number;
v_jum number;
begin
    select sum into v_jum
    from data
    where id_data= :new.id_data;

    select sum_total into v_stok
    from tool
    where id_tool= 
    (select id_tool
        from data
        where id_data= :new.id_data);

    if inserting then
    v_stok := v_stok + v_jum;
    update tool
    set sum_total=v_stok
    where id_tool=
    (select id_tool
        from data
        where id_data= :new.id_data);
    end if;
end;

/

please give me opinion.
Thanks.

  • 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-06-16T15:15:10+00:00Added an answer on June 16, 2026 at 3:15 pm

    The ora-04090 indicates that you already have an AFTER INSERT … FOR EACH ROW trigger on that table. Oracle doesn’t like that, because the order in which the triggers fire is unpredictable, which may lead to unpredictable results, and Oracle really doesn’t like those.

    So, your first step is to merge the two sets of code into a single trigger. Then the real fun begins.

    Presumably there is only one row in data matching the current value of id_data (if not your data model is rally messed up and there’s no hope for your situation). Anyway, that means the current row already gives you access to the values of :new.sum and :new.id_tool. So you don’t need those queries on the data table: removing those selects will remove the possibility of "mutating table" errors.

    As a general observation, maintaining aggregate or summary tables like this is generally a bad idea. Usually it is better just to query the information when it is needed. If you really have huge volumes of data then you should use a materialized view to maintain the summary, rather than hand-rolling something.

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

Sidebar

Related Questions

I have this question about the JVM running my Java code. My friend has
I have a general question about desktop applications. My friend and I were discussing
I Have an MS Access Db that I built for a friend about 8
I have used Java, C++, .Net. (in that order). When asked about by-value vs.
There are plenty of question about join on the same table, but I can't
This may be a newbie question, But let's say I have a database table
I have a random question about const correctness. Lets say i have a class
Hi I have a question about my writing to my database: I'm new to
can I have a question about how to redirect the page after user invite
I'm developing Wordpress theme for my friend's company, but this question is all about

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.