What's your version of Oracle?  I usually have a stock answer on how to
solve this type of problem, but I just tried out your problem on my little
Personal Oracle here, and to my INCREDIBLE surprise, the trigger worked and
I didn't get an error.  Does anyone know if that's just because I'm using
Personal Oracle, or did they actually manage to guarantee consistency when
the tables are mutating in 8.1.6?  This is the trigger text I used:

     create or replace trigger bir_tableB
     before insert on tableB
     for each row
     declare
          cursor get_max_date is
               select max(create_date)
               from tableB;
          maxDate   date;
     begin
          open get_max_date;
          fetch get_max_date into maxDate;
          close get_max_date;

          if (:new.create_date < nvl(maxDate, :new.create_date)) then
               raise_application_error(-20101, 'New date must be greater
than any existing record.');
          end if;
     end bir_tableB;

Diana Duncan
TITAN Technology Partners
One Copley Parkway, Ste 540
Morrisville, NC  27560
VM: 919.466.7337 x 316
F: 919.466.7427
E: [EMAIL PROTECTED]


                                                                                       
                            
                    Leslie Lu                                                          
                            
                    <leslie_y_lu@        To:     Multiple recipients of list ORACLE-L 
<[EMAIL PROTECTED]>       
                    yahoo.com>           cc:                                           
                            
                    Sent by:             Fax to:                                       
                            
                    root@fatcity.        Subject:     in addition -- ORA-04091: table 
mutating problem?            
                    com                                                                
                            
                                                                                       
                            
                                                                                       
                            
                    05/03/2001                                                         
                            
                    07:11 PM                                                           
                            
                    Please                                                             
                            
                    respond to                                                         
                            
                    ORACLE-L                                                           
                            
                                                                                       
                            
                                                                                       
                            




In addition to my previous question:

supposed you cannot use Max(date), and MUST use the
cursor.  (may be my example is not a good one),
anyway, I'd like to know how to get around this
mutating problem.  Thank you!

--- Leslie Lu <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I got ORA-04091: table mutating problem.  Here is
> the
> case: select from table A and insert them into table
> B.  A trigger is used to check that new DATE must be
> later than every DATE in B.  So I open an cursor,
> loop
> through cursor to compare new DATE value.
>
> If I tested using hard coded value, the trigger
> works;
> if do a insert ... select, I got ORA-04091.
>
> I looked through metalink, didn't see anything that
> can help.
>
> Thank you in advance.
>
> Leslie
>





-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to