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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:07:46+00:00 2026-06-14T18:07:46+00:00

This trigger will pass on inserted values to a procedure which will insert those

  • 0

This trigger will pass on inserted values to a procedure which will insert those values in another table. I’m getting a mutating table error. How can i fix this?

CREATE OR REPLACE TRIGGER ADD_INVOICE
BEFORE INSERT OR UPDATE OF APP_NO,C_NO ON APPOINTMENT
FOR EACH ROW
DECLARE
BEGIN

POP_INVOICE(:NEW.APP_NO,:NEW.C_NO,:NEW.APP_DATE);

END;
/

CREATE OR REPLACE PROCEDURE POP_INVOICE(
I_APP_NO IN INVOICE.APP_NO%TYPE,
I_C_NO IN INVOICE.C_NO%TYPE,
I_INV_DATE IN INVOICE.INV_DATE%TYPE)
AS
CURSOR C_POP IS SELECT PRICE FROM TREATMENT T,APPOINTMENT A 
WHERE T.TRT_NO=A.TRT_NO
AND A.APP_NO=I_APP_NO;

V_BILL INVOICE.BILL%TYPE;
BEGIN

OPEN C_POP; 
FETCH C_POP INTO V_BILL;

UPDATE INVOICE
SET INV_NO=INV_IDSEQ.NEXTVAL,
APP_NO=I_APP_NO,
C_NO=I_C_NO,
BILL=V_BILL,
INV_DATE=I_INV_DATE;

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-06-14T18:07:47+00:00Added an answer on June 14, 2026 at 6:07 pm

    The problem is caused by referencing the table with the trigger on it within the trigger itself. Changing the procedure to accept the TRT_NO as a parameter removes the need to include APPOINTMENT in the query, and so will avoid the mutating table exception. Depending on how many records there are for each treatment, you could even incorporate the cursor into your UPDATE statement.

    I think this should do it, although I haven’t been able to check against a database.

    CREATE OR REPLACE TRIGGER ADD_INVOICE
    
    BEFORE INSERT OR UPDATE OF APP_NO,C_NO ON APPOINTMENT
    FOR EACH ROW
    DECLARE
    BEGIN
    
    POP_INVOICE(:NEW.APP_NO,:NEW.C_NO,:NEW.APP_DATE,:NEW.TRT_NO);
    
    END;
    /
    

    The revised procedure:

    CREATE OR REPLACE PROCEDURE POP_INVOICE(
    I_APP_NO IN INVOICE.APP_NO%TYPE,
    I_C_NO IN INVOICE.C_NO%TYPE,
    I_INV_DATE IN INVOICE.INV_DATE%TYPE,
    I_TRT_NO IN APPOINTMENT.TRT_NO%TYPE
    )
    AS
    
    CURSOR C_POP IS SELECT PRICE 
    FROM TREATMENT T
    WHERE T.TRT_NO = I_TRT_NO;
    
    V_BILL INVOICE.BILL%TYPE;
    
    BEGIN
    
    OPEN C_POP; 
    FETCH C_POP INTO V_BILL;
    CLOSE C_POP;
    
    INSERT INVOICE
      (inv_no, app_no, c_no, bill, inv_date)
    VALUES
      (INV_IDSEQ.NEXTVAL, I_APP_NO, I_C_NO, V_BILL, I_INV_DATE);
    
    
    END;
    /
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does this mean I can't update another table from a trigger if I'm using
My trigger takes an input. (NEW:input_id) With this input, it will generate new ID's
I have this trigger which works functionally (as far as I can tell by
There is something wrong with this trigger. But what? CREATE TRIGGER MYCOOLTRIGGER AFTER INSERT
I am trying to update a table according to this trigger: CREATE TRIGGER alert
When I pass 'this' to an anonymous function like so: MyClass.prototype.trigger = function(){ window.setTimeout(function(){this.onTimeout();},1000);
Why does this trigger work (Changing the foreground of the button to Red when
Let's say I've got a trigger like this: CREATE TRIGGER trigger1 ON [dbo].[table1] AFTER
I'm using SQL Server 2008. I'm creating a DDL trigger like this: CREATE TRIGGER
I have a trigger that looks something like this: create or replace TRIGGER cluster_check

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.