declare cost float :=0; myFlav varchar2(20); cursor pastry is select * from goods where flavor = 'Chocolate'; myPastry pastry%rowtype; begin dbms_output.enable; open pastry; loop fetch pastry into myPastry; exit when pastry%notfound; cost := cost + myPastry.Price; end loop; close pastry; dbms_output.put_line('Cost of all Chocolate items is '|| cost); end; /