Ana stok miktarlarını çeşitlerine göre güncellemek için aşağıdaki kodu çalıştırınız. 123456789 yazan yere ilgili ana stok kartının kayıt numarasını giriniz.
execute block
returns(
xkonum_k k,xgiris miktar, xcikis miktar, xmiktar miktar
)
as
declare variable xstok_k k;
begin
xstok_k=123456789;
for select k from konum into :xkonum_k do
begin
select sum(giris),sum(cikis),sum(miktar) from stokmiktar sm join stok s on sm.konum_k=:xkonum_k and sm.stok_k=s.k and s.ustk=:xstok_k into :xgiris,:xcikis,:xmiktar;
update stokmiktar set giris=:xgiris,cikis=:xcikis,miktar=:xmiktar where konum_k=:xkonum_k and stok_k=:xstok_k;
suspend;
end
end