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

  • Home
  • SEARCH
  • 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 557441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:01:35+00:00 2026-05-13T12:01:35+00:00

I have this table that represents a weak entity and is a typical table

  • 0

I have this table that represents a weak entity and is a typical table for introducing items ordered:
insert into ITEM_FORNECIMENTO values (a_orderId,a_prodId,a_prodQtd, a_buyPrice);

I want my trigger to update the last column (the total price of products WITHOUT iva) to do this : totalPrice= totalPrice*(1+(iva/100), each time I insert or update an entry on that table.

so, I came up with this, but I’m totally wrong when it comes to work with new and old values.

create or replace
trigger t_replaceTotal
after insert or update of id_prod,qtd_if,prec_total_if on item_fornecimento
for each row 

declare
iva produto.iva_prod%type;
idProd  produto.id_prod%type;
r_old item_fornecimento.prec_total_if%type:=null;
r_new item_fornecimento.prec_total_if%type:=null;

begin
  select iva_prod,id_prod into iva,idprod from produto p where p.id_prod = id_prod; 
  r_old:= :old.prec_total_if;
  r_new:= :new.prec_total_if;
  update item_fornecimento item set prec_total_if = r_old * (1+(iva/100)) where item.id_prod = idprod;
end;

Could someone please help rewriting this code? I’m getting the error: ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at “FUSION.T_REPLACETOTAL”, line 8
ORA-04088: error during execution of trigger ‘FUSION.T_REPLACETOTAL’

  • 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-13T12:01:36+00:00Added an answer on May 13, 2026 at 12:01 pm

    The problem is that you are trying to fetch every row from the table because you are matching a column (id_prod) to itself. I suspect you want to use :new.id_prod or :old.id_prod.

    select .... from produto p where p.id_prod = id_prod; 
    

    Next, make this a BEFORE INSERT/UPDATE trigger and replace the UPDATE statement with

     :new.prec_total_if := r_old * (1+(iva/100));
    

    Otherwise you’ll get a mess of mutating table errors.

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

Sidebar

Related Questions

suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
Say I have a schema that represents a fixed-depth hierarchy like this: CREATE TABLE
I have a table that is created in a DataList in ASP.Net. This table
I have a table that looks something like this: word big expensive smart fast
I have a table that looks a bit like this actors(forename, surname, stage_name); I
I have this .NET web app that draws a table in Page_Load. Then after
I have an HTML table that looks like this: ------------------------------------------------- |Column 1 |Column 2
I have a database that contains a table that looks a bit like this:
This is for MySQL and PHP I have a table that contains the following
Ok I'm at my work this friday setting up a table that will have

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.