posted 9 years ago
I have written following PL/SQL codes
set serveroutput on
declare
cursor matchqty is select pid,productname,quantity,price from store;
cursor match2qty is select pid,productname,quantity,price from cart;
diff number;
pid1 store.pid%type;
pid2 cart.pid%type;
pname1 store.productname%type;
pname2 cart.productname%type;
qty1 store.quantity%type;
qty2 cart.quantity%type;
price1 store.price%type;
price2 cart.price%type;
begin
open matchqty;
if(matchqty%isopen) then
loop
fetch matchqty into pid1,pname1,qty1,price1;
exit when matchqty%notfound;
end loop;
end if;
open match2qty;
if(match2qty%isopen) then
loop
fetch match2qty into pid2,pname2,qty2,price2;
exit when match2qty%notfound;
end loop;
end if;
diff:=qty1-qty2;
dbms_output.put_line(diff);
close matchqty;
close match2qty;
end;
/
But it is displaying difference of quantity for only last record, please help me by telling how to display difference of quantities of all records.