Код:cursor getsmspec2(i integer) is select a.awaittotalprice p1,a.awaittotalpricecur p2,b.itemprice pr1,b.totalprice pr2,b.itempricenotax pr3,b.totalpricenotax pr4,b.itempricecur pr5,b.totalpricecur pr6,b.article art from supermag.smspecrl a,supermag.smspec b where a.specitem=i and b.specitem=i and a.docid='СВ13000001' and b.docid='СВ13000001'; begin l:=0; FOR i in 1..1000 LOOP for df in getsmspec2(i) loop select g.taxgroupid into tax from supermag.smcardtax g where g.article=df.art and rownum=1 order by g.datefrom asc; l:=l+1; if (tax=1) then nds:=1; end if; if (tax=4) then nds:=1; end if; if (tax=2) then nds:=1.1; end if; if (tax=3) then nds:=1.18; end if; p1:=(round((df.p1/nds),2)); p2:=(round((df.p2/nds),2)); pr1:=(round((df.pr1/nds),2)); pr2:=(round((df.pr2/nds),2)); pr3:=(round((df.pr3/nds),2)); pr4:=(round((df.pr4/nds),2)); pr5:=(round((df.pr5/nds),2)); pr6:=(round((df.pr6/nds),2)); update smspecrl set awaittotalprice=p1,awaittotalpricecur=p2 where docid='СВ13000001' and specitem=i ; update smspec set itemprice=pr1,totalprice=pr2,itempricenotax=pr3,totalpricenotax=pr4,itempricecur=pr5,totalpricecur=pr6 where docid='СВ13000001' and specitem=i; end loop; end loop; end; / commit; spool off