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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:57:21+00:00 2026-06-01T04:57:21+00:00

I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE

  • 0

I have a table trigger like below:

CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG
 BEFORE UPDATE OF DOB
 ON PAT
 REFERENCING OLD AS OLD NEW AS NEW
 FOR EACH ROW
-- PL/SQL Block
begin
  tgln_sys_error_pkg.compare_dates(trunc(add_months(:new.dob, -12)),
                                   trunc(tgln_sys_error_pkg.GET_LIST_DATE(:old.pat_id)),
                                   tgln_sys_errnums_pkg.en_retr_waitlist_date);
end;

-------------------------------------- 

I have a package which is called by the trigger above, the code for the package is like below:

CREATE OR REPLACE PACKAGE TGLN_SYS_ERROR_PKG AS

/* To compare two dates against each other. */
PROCEDURE COMPARE_DATES
(P_DATE_LOW date
,P_DATE_HIGH date
,P_ERROR_CODE number
);

FUNCTION GET_LIST_DATE
 (P_PAT_ID number)
 RETURN DATE;

END TGLN_SYS_ERROR_PKG;
--------------------------------------   

The package body is like below:

CREATE OR REPLACE PACKAGE BODY TGLN_SYS_ERROR_PKG AS

FUNCTION GET_LIST_DATE(P_PAT_ID number) RETURN DATE IS
  v_ret_date date;
begin

  --select to_date('01-JAN-1980') into p_Date from dual; 

  select max(pwl.eff_date)
    into v_ret_date
    from pat, pat_register pr, pat_register_org_det prod, pat_wait_list pwl
   where pat.pat_id = pr.pat_id
     and pr.patr_id = prod.patr_id
     and prod.prod_id = pwl.prod_id
     and pat.pat_id = P_PAT_ID
     and rownum < 2
     AND pwl.exp_date is null;
  return nvl(v_ret_date, to_date(null));
exception
  when no_data_found then
    return to_date(null);
end GET_LIST_DATE;


PROCEDURE COMPARE_DATES
(P_DATE_LOW date
,P_DATE_HIGH date
,P_ERROR_CODE number
)
IS
begin
if nvl(p_date_low,sysdate-10000)>nvl(p_date_high,sysdate+10000) then
raise_application_error(p_error_code,null);
end if;
end compare_dates;

end TGLN_SYS_ERROR_PKG;
--------------------------------------    
CREATE OR REPLACE PACKAGE TGLN_SYS_ERRNUMS_PKG IS
en_retr_waitlist_date CONSTANT INTEGER := -20088; --Patient waitlist effective dates must not be less than or equal to patient's date of birth minus one year ( DOB - 1 year).     
END TGLN_SYS_ERRNUMS_PKG;
-------------------------------------- 

Each time when Oracle Forms update DOB data, I get error like below:

Oracle Form FRM-40735: ON-ERROR trigger raised unhandled exception ORA-06502

But, when I hard code like below:

select to_date('01-JAN-1980') into p_Date from dual; 

to instead of this paragraph code like below, form works fine.

  select max(pwl.eff_date)
    into v_ret_date
    from pat, pat_register pr, pat_register_org_det prod, pat_wait_list pwl
   where pat.pat_id = pr.pat_id
     and pr.patr_id = prod.patr_id
     and prod.prod_id = pwl.prod_id
     and pat.pat_id = P_PAT_ID
     and rownum < 2
     AND pwl.exp_date is null;

I did replace p_pat_id to a real value, it pops up a trigger error

ORA-04091: table TGLN.PAT is mutating, trigger/function may not see it 
ORA-06512: at "TGLN.TGLN_SYS_ERROR_PKG",
line 130 ORA-06512: at "TGLN.PAT_BUR_DOB_TRG",
line 26 ORA-04088: error during execution of trigger 'TGLN.PAT_BUR_DOB_TRG'
View program sources of error stack?" 

So, how to fix the bug? I can not hard code the date values

  • 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-01T04:57:22+00:00Added an answer on June 1, 2026 at 4:57 am

    Error:

    ORA-04091: table name is mutating, trigger/function may not see it/

    Your Error

    trigger error:"ORA-04091: table TGLN.PAT is mutating

    Cause:

    A statement executed a trigger or custom PL/SQL function. That trigger/function tried to modify or query a table that is currently being modified by the statement that fired the trigger/function.

    Your Cause

     --you're not supposed to query a table that is currently modified 
     --In you're case its `PAT` table being updated and querying at same time
     select max(pwl.eff_date)
     into v_ret_date
     from pat,  --here you are querying your PAT table,while updating the same table
          pat_register pr, pat_register_org_det prod, pat_wait_list pwl
      where pat.pat_id = pr.pat_id
       and pr.patr_id = prod.patr_id
       and prod.prod_id = pwl.prod_id
       and pat.pat_id = P_PAT_ID
       and rownum < 2
       AND pwl.exp_date is null;
    

    Action:

    The options to resolve this Oracle error are:
    Re-write the trigger/function so that it does not try to modify/query the table PAT in question.

    Reference

    • ORA-04091 Error

    • ORA-04091: table [blah] is mutating, trigger/function may not see it

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

Sidebar

Related Questions

If I have a trigger before the update on a table, how can I
I'm new to triggers . I have table like this CREATE TABLE [dbo].[Positions]( [Id]
I have a table where on a single record update, a trigger adds a
I have a pg table like this: CREATE TABLE order_status_history ( order_id integer NOT
I have one question regarding trigger. The scenario is like this Create Procedure begin
I have the trigger in one table and would like to read UserId value
I have a table that simplified looks like this: create table Test ( ValidFrom
I have a table that has an insert trigger on it. If I insert
We have created a table with a trigger that updates a ModifiedDate field in
I have a table in a SQL Server 2005 database with a trigger that

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.