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 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

Ask A Question

Stats

  • Questions 534k
  • Answers 534k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Stabbing in the dark here, but is this what you… May 17, 2026 at 12:40 am
  • Editorial Team
    Editorial Team added an answer You can try using text in varchar in the address… May 17, 2026 at 12:40 am
  • Editorial Team
    Editorial Team added an answer If you have skills with server-side programming (PHP, ASP, ASP.Net,… May 17, 2026 at 12:40 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Say I have a schema that represents a fixed-depth hierarchy like this: CREATE TABLE
I have a table that represents a series of matches between ids from another
I have a table that represents Tab-structure. Some cells are set to display: none;
I have a table that represents a list of countries. I have another table
I have a Database table that I want to display in a DataGridView. However,
I have some data in string format that represents binary data (e.g. '0x0002'). Is
I have a UITableView that represents a list of objects, I'd like the user
The problem is the following, I have a table of friendships in my database,
I’m building an application where different users will have different menu items available to
I'm trying to create a LINQ to SQL class that represents the latest version

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.