cursor [message #1611] |
Thu, 16 May 2002 00:08 |
shofi
Messages: 9 Registered: October 2001
|
Junior Member |
|
|
Hellow everybody,
I have a cursor, it is working but if I run it everytime the last record is inserting two times. Could any body help me? The cursor is given below:
declare
cursor history
is
select * from employee_payment;
id employee_payment.id%type;
name employee_payment.name%type;
dpm employee_payment.deptname%type;
outlet employee_payment.outlet%type;
mop employee_payment.paydate%type;
basic employee_payment.basic%type;
houserent employee_payment.houserent%type;
conveyance employee_payment.conveyance%type;
fmedical employee_payment.fmedical%type;
ta employee_payment.totalallowance%type;
adj employee_payment.arrearadjustment%type;
misc employee_payment.misc%type;
ts employee_payment.totalsalary%type;
begin
open history;
loop
fetch history into id,name,dpm,outlet,mop,basic,houserent,conveyance,fmedical,ta,adj,misc,ts;
insert into employee_payment_history
values(seq_his.nextval,id,name,dpm,outlet,mop,basic,houserent,conveyance,fmedical,ta,adj,misc,ts);
exit when history%notfound;
end loop;
close history;
commit;
end;
/
|
|
|
Re: cursor [message #1613 is a reply to message #1611] |
Thu, 16 May 2002 00:25 |
seng
Messages: 191 Registered: February 2002
|
Senior Member |
|
|
the insert statement should put after this
"exit when history%notfound" , because when the cursor is check to last record, this "exit when history%notfound" will return true, and loop up before exit by this statement "exit when history%notfound". this inserts another record in again. hope this is helping.
|
|
|