Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> PL/SQL question

PL/SQL question

From: clint <c_macnichol_at_hotmail.com>
Date: Fri, 04 Apr 2003 12:36:38 GMT
Message-ID: <q%eja.660$UA6.56758@ursa-nb00s0.nbnet.nb.ca>


I have a pl/sql script that works...except it seems to repeat the last result twice:

I have table A with 2 entries....I use my pl/sql script to send altered results to table B. But when I check table B, I see that there is three results instead of 2.

Table A
  EMPLO_ID NUM_MILES
---------- ----------

     20029       1758
     20030        358

Table B
 EMPLO_ID     AMOUNT

---------- ----------
20029 281.28 20030 57.28 20030 57.28

And here is the script is am using....
DECLARE
CURSOR c_MILEAGE_CAL IS
SELECT EMPLO_ID, NUM_MILES, MIL_ALLOWANCE, ENTRY_DATE, DESCR FROM MILE_LOG;

V_EMPLOID MILE_LOG.EMPLO_ID%TYPE;
V_NUM_MILES MILE_LOG.NUM_MILES%TYPE;
V_CENTSPERMILE MILE_LOG.MIL_ALLOWANCE%TYPE;
V_DATE DATE;
V_DESCR MILE_LOG.DESCR%TYPE;
V_REFUND NUMBER(8,2);

BEGIN
 OPEN c_MILEAGE_CAL;
 LOOP
 EXIT WHEN c_MILEAGE_CAL%NOTFOUND;
 FETCH c_MILEAGE_CAL INTO
 V_EMPLOID, V_NUM_MILES, V_CENTSPERMILE, V_DATE, V_DESCR;  V_REFUND := V_NUM_MILES * V_CENTSPERMILE;  INSERT INTO EXPENSE_LOG
  VALUES(EXPLOG_COUNT_SEQ.NEXTVAL,V_EMPLOID,11004,V_REFUND,V_DATE, V_DESCR, V_NUM_MILES );
 END LOOP;
CLOSE c_MILEAGE_CAL;
COMMIT;
END; Received on Fri Apr 04 2003 - 06:36:38 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US