Home » RDBMS Server » Server Administration » A question about ora-06512
A question about ora-06512 [message #117908] Sun, 01 May 2005 08:45 Go to next message
GuteNacht
Messages: 16
Registered: April 2005
Junior Member
Hi

There is a trigger called "mao". In this trigger, it calls a procedure called "month"

when I updated a table "report" which impacted the trigger, I came across these errors:

update report
*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "SYSTEM.MONTH", line 177
ORA-06512: at "SYSTEM.MAO", line 21
ORA-04088: error during execution of trigger 'SYSTEM.MAO'

but in fact, there is no errors in month and mao.

alter procedure month compile
procedure altered.

alter trigger mao compile
trigger altered

I wonder how these errors happened and how to solve them.

I greatly appreciate it!

Norah


Re: A question about ora-06512 [message #117910 is a reply to message #117908] Sun, 01 May 2005 08:57 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
You get a no_data_found error in the procedure/function month; it is not a syntax error but a programmatic error.

btw, do NOT use the SYSTEM account for your own tables.

hth
Re: A question about ora-06512 [message #117912 is a reply to message #117910] Sun, 01 May 2005 09:03 Go to previous messageGo to next message
GuteNacht
Messages: 16
Registered: April 2005
Junior Member
Frank wrote on Sun, 01 May 2005 09:57

You get a no_data_found error in the procedure/function month; it is not a syntax error but a programmatic error.

btw, do NOT use the SYSTEM account for your own tables.

hth


Thank you very much.

It is a small system. So we just use "system".

But I am confused that what is programmatic here. I am a green hand in Oracle. So would you please provide me more details in this solution?

Thank you very much!

Norah

Re: A question about ora-06512 [message #117918 is a reply to message #117908] Sun, 01 May 2005 11:15 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
When you get a bunch of errors like you did
Quote:

ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "SYSTEM.MONTH", line 177
ORA-06512: at "SYSTEM.MAO", line 21
ORA-04088: error during execution of trigger 'SYSTEM.MAO'


the actual error is the first one mentioned (No data found) The rest is the call-stack towards the program where the error arose.

No data found means you did a select ... into ... and there was no row found, or you make a reference to an invalid index in a pl/sql table.
Search the documentation for NO_DATA_FOUND; I'm quite sure it will help you.

And, even for small applications, still do not use the SYSTEM account. It's just not done; it's Oracles own account and we should not mess with it.

hth
Re: A question about ora-06512 [message #118004 is a reply to message #117908] Mon, 02 May 2005 09:38 Go to previous messageGo to next message
smartin
Messages: 1803
Registered: March 2005
Location: Jacksonville, Florida
Senior Member
Frank is right, do not use the system account no matter the size of your system.
Re: A question about ora-06512 [message #118086 is a reply to message #117918] Tue, 03 May 2005 00:11 Go to previous messageGo to next message
girish.rohini
Messages: 744
Registered: April 2005
Location: Delhi (India)
Senior Member
HI

To resolve the NO_DATA_FOUND error make use of explicit cursors and their functionality %found %notfound.

Regds
Girish
Re: A question about ora-06512 [message #118710 is a reply to message #117918] Sat, 07 May 2005 03:20 Go to previous messageGo to next message
GuteNacht
Messages: 16
Registered: April 2005
Junior Member
Frank wrote on Sun, 01 May 2005 12:15

When you get a bunch of errors like you did
Quote:

ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "SYSTEM.MONTH", line 177
ORA-06512: at "SYSTEM.MAO", line 21
ORA-04088: error during execution of trigger 'SYSTEM.MAO'


the actual error is the first one mentioned (No data found) The rest is the call-stack towards the program where the error arose.

No data found means you did a select ... into ... and there was no row found, or you make a reference to an invalid index in a pl/sql table.
Search the documentation for NO_DATA_FOUND; I'm quite sure it will help you.

And, even for small applications, still do not use the SYSTEM account. It's just not done; it's Oracles own account and we should not mess with it.

hth

Thank you very much for the advice above mentioned.

But I am sorry that I am still confused in this problem
The procedure is:

...
v_workmonth oworkdays.thismonth%TYPE;
...
v_workmonth := TO_CHAR( bgtime_arg, 'MON');
...
SELECT workdays (line 177)
INTO n_workdays
FROM oworkdays
WHERE thismonth=v_workmonth;

I checked the table oworkdays. It surely contained data. Then how did it come?
Re: A question about ora-06512 [message #118713 is a reply to message #117908] Sat, 07 May 2005 04:02 Go to previous messageGo to next message
tycoonajayverma
Messages: 17
Registered: May 2005
Location: b'lore
Junior Member

Hi

can u provide the source code of the procedure so that i have a look into it and one more thing ur updating table with this proc.
the condition u r using in it. it has the data in the table if yes the provide the procedure.


Thanks
Re: A question about ora-06512 [message #118716 is a reply to message #118713] Sat, 07 May 2005 04:29 Go to previous messageGo to next message
GuteNacht
Messages: 16
Registered: April 2005
Junior Member
tycoonajayverma wrote on Sat, 07 May 2005 05:02

Hi

can u provide the source code of the procedure so that i have a look into it and one more thing ur updating table with this proc.
the condition u r using in it. it has the data in the table if yes the provide the procedure.


Thanks


The procedure is:
PROCEDURE monthly1( bgtime_arg DATE, endtime_arg DATE ) AS
   CURSOR c_pdno IS
      SELECT pdno FROM epdno;

   CURSOR c_input IS
      SELECT pdno, SUM(finum)
      FROM oltstate
      WHERE fidate >= bgtime_arg AND fidate < endtime_arg AND UPPER(state) = 'P'

      GROUP BY pdno


      ORDER BY pdno;

   CURSOR c_inputinv IS
      SELECT pdno, SUM(wfnum)
      FROM oltinv
      WHERE outtime >= bgtime_arg AND outtime < endtime_arg
      GROUP BY pdno
      ORDER BY pdno;

   CURSOR c_output IS
      SELECT pdno, SUM(fonum)


      FROM oltstate
      WHERE outpdate >= bgtime_arg AND outpdate < endtime_arg
      GROUP BY pdno
      ORDER BY pdno;

   CURSOR c_outputinv IS
      SELECT pdno, SUM(wfnum)
      FROM oltinv
      WHERE intime >= bgtime_arg AND intime < endtime_arg
      GROUP BY pdno
      ORDER BY pdno;


   CURSOR c_scrapfab IS
      SELECT pdno, SUM(bknwfs)
      FROM obknwfs
      WHERE thisday >= bgtime_arg AND thisday < endtime_arg
      GROUP BY pdno
      ORDER BY pdno;

   CURSOR c_wip IS
      SELECT pdno, SUM(wfnum)
      FROM oltno


      GROUP BY pdno
      ORDER BY pdno;

   CURSOR c_leadtime IS
      SELECT pdno, MIN(CEIL(fodate-fidate)) || ' - ' || MAX(CEIL(fodat
e-fidate))

      FROM oltstate
      WHERE outpdate >= bgtime_arg AND outpdate < endtime_arg
      GROUP BY pdno
      ORDER BY pdno;



   v_pdno         omonthlyreport1.pdno%TYPE;
   n_wafers       NUMBER;
   v_leadtime     omonthlyreport1.leadtime%TYPE;
   v_month        omonthlyreport1.thismonth%TYPE;
   n_workdays     NUMBER;
   n_outsum       NUMBER;
   n_scrapsum     NUMBER;
   [color=skyblue][color=skyblue][color=red]v_workmonth    oworkdays.thismonth%TYPE;[/color][/color][/color]
BEGIN
   v_month := TO_CHAR( bgtime_arg, 'YYYY MON' );


  [color=red] v_workmonth := TO_CHAR( bgtime_arg, 'MON');[/color]
   OPEN c_pdno;
   LOOP
      FETCH c_pdno INTO v_pdno;
      EXIT WHEN c_pdno%NOTFOUND;
      INSERT INTO omonthlyreport1(thismonth, pdno)
         VALUES(v_month,v_pdno);
   END LOOP;
   CLOSE c_pdno;



   OPEN c_input;
   LOOP
      FETCH c_input INTO v_pdno, n_wafers;
      EXIT WHEN c_input%NOTFOUND;
      UPDATE omonthlyreport1
         SET input = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_input;

   OPEN c_inputinv;


   LOOP
      FETCH c_inputinv INTO v_pdno, n_wafers;
      EXIT WHEN c_inputinv%NOTFOUND;
      UPDATE omonthlyreport1
         SET inputinv = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_inputinv;

   OPEN c_output;
   LOOP


      FETCH c_output INTO v_pdno, n_wafers;
      EXIT WHEN c_output%NOTFOUND;
      UPDATE omonthlyreport1
         SET output = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
      UPDATE oplan
         SET lastout = n_wafers, lastplan = thisplan, thisplan = NULL
         WHERE UPPER(pdno) = UPPER(v_pdno);
   END LOOP;
   CLOSE c_output;



   OPEN c_outputinv;
   LOOP
      FETCH c_outputinv INTO v_pdno, n_wafers;
      EXIT WHEN c_outputinv%NOTFOUND;
      UPDATE omonthlyreport1
         SET outputinv = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_outputinv;

   OPEN c_scrapfab;


   LOOP
      FETCH c_scrapfab INTO v_pdno, n_wafers;
      EXIT WHEN c_scrapfab%NOTFOUND;
      UPDATE omonthlyreport1
         SET scrapfab = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_scrapfab;

   OPEN c_wip;
   LOOP


      FETCH c_wip INTO v_pdno, n_wafers;
      EXIT WHEN c_wip%NOTFOUND;
      UPDATE omonthlyreport1
         SET wip = n_wafers
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_wip;

   OPEN c_leadtime;
   LOOP
      FETCH c_leadtime INTO v_pdno, v_leadtime;


      EXIT WHEN c_leadtime%NOTFOUND;
      UPDATE omonthlyreport1
         SET leadtime = v_leadtime
         WHERE UPPER(pdno) = UPPER(v_pdno) AND thismonth=v_month;
   END LOOP;
   CLOSE c_leadtime;



   INSERT INTO omonthlyreport1(thismonth, pdno)
      VALUES(v_month, 'zz1_total');


   SELECT MIN(CEIL(fodate-fidate)) || ' - ' || MAX(CEIL(fodate-fidate))

      INTO v_leadtime
      FROM oltstate
      WHERE outpdate >= bgtime_arg AND outpdate < endtime_arg;
   UPDATE omonthlyreport1
      SET ( input, inputinv, output, outputinv, scrapfab, scraptest, wip)

              = ( SELECT SUM(input), SUM(inputinv), SUM(output), SUM(outputinv),

                         SUM(scrapfab), SUM(scraptest), SUM(wip)
                  FROM omonthlyreport1
                    WHERE thismonth=v_month ),
          leadtime = v_leadtime
      WHERE thismonth=v_month AND pdno='zz1_total';

   SELECT NVL(output,0) + NVL(outputinv,0) + NVL(scrapfab,0) + NVL(scraptest,0),

          NVL(scrapfab,0) + NVL(scraptest,0)
      INTO n_outsum, n_scrapsum
      FROM omonthlyreport1
      WHERE thismonth=v_month AND pdno='zz1_total';
   INSERT INTO omonthlyreport1(thismonth, pdno, scrapfab)
      VALUES(v_month, 'zz2_scrapsum', n_scrapsum);

   INSERT INTO omonthlyreport1(thismonth, pdno)

      VALUES(v_month, 'zz3_average');
[color=red]   SELECT workdays
      INTO n_workdays
      FROM oworkdays
      WHERE thismonth=v_workmonth;[/color]   SELECT TO_CHAR( TRUNC(SUM(CEIL(fodate-fidate))/COUNT(*)) )
      INTO v_leadtime
      FROM oltstate
      WHERE outpdate >= bgtime_arg AND outpdate < endtime_arg;
   UPDATE omonthlyreport1
      SET ( input, inputinv, output, outputinv, scrapfab, scraptest )
              = ( SELECT input/n_workdays, inputinv/n_workdays, output/n_workdays,
                         outputinv/n_workdays, scrapfab/n_workdays, scraptest/n_workdays

                  FROM omonthlyreport1
                  WHERE thismonth=v_month AND pdno='zz1_total' ),
          leadtime = v_leadtime
      WHERE thismonth=v_month AND pdno='zz3_average';

   INSERT INTO omonthlyreport1(thismonth, pdno, scrapfab)
      VALUES(v_month, 'zz4_scraprat', (n_scrapsum/n_outsum)*100);
   INSERT INTO omonthlyreport1(thismonth, pdno, output)
      VALUES(v_month, 'zz5_yield', 100-(n_scrapsum/n_outsum)*100);

END monthly1;

The procedure is a little long and I think the red font has the relevance with this problem.

The trigger is:
CREATE OR REPLACE TRIGGER mao
   AFTER UPDATE OF updatetime 
   ON report_trigger
   FOR EACH ROW
DECLARE
   d_endtime report.endtime%TYPE;
   d_today   DATE;
BEGIN
   SELECT endtime
      INTO d_endtime
      FROM report
      WHERE id=:new.id;
   d_today := SYSDATE ;
IF :new.id = 99 AND TO_CHAR(d_endtime,'MON') != TO_CHAR(d_today,'MON') THEN
      monthly1( d_endtime, d_today );
      monthly3( d_endtime, d_today );
      monthly4( d_endtime, d_today );
      monthly5( d_endtime, d_today );
   END IF; 

   UPDATE report
      SET bgtime = d_endtime, endtime = d_today
      WHERE id=:new.id;
   
END after_update_report_trigger;


And the table is
id        updatetime
99        2005-4-27 20:00:09


I greatly appreciate your help!

Norah
Re: A question about ora-06512 [message #118825 is a reply to message #117908] Mon, 09 May 2005 01:49 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
Quote:

ORA-01403: no data found
ORA-06512: at "SYSTEM.MONTH", line 177
ORA-06512: at "SYSTEM.MAO", line 21
ORA-04088: error during execution of trigger 'SYSTEM.MAO'


You have no procedure month, so I take it your renamed it to monthly1.

Check all places where you do an explicit 'select into'. Output the values you use in the where-clause to see if you always get a row.
(SELECT NVL(output,0) + NVL(outputinv,0) + NVL(scrapfab,0) + NVL(scraptest,0),NVL(scrapfab,0) + NVL(scraptest,0)
INTO n_outsum, n_scrapsum
FROM omonthlyreport1
...
or the one you pointed out.

It has to be one of those

hth
Previous Topic: Apache error
Next Topic: help urgent
Goto Forum:
  


Current Time: Fri Jan 10 04:43:17 CST 2025