UMA AJUDA EM UMA FUNCTION
ola caros programadores, preciso de uma luz , eu uso firebird sempre fiz procedure mais estou migrando para postgre mais estou certa duvida de como fazer function pra baixar estoque vou colocar a minha que faço no firebird
ela faz um lop na tabela item e verefica se é um kit pra buscar em outra
if ( :OPE = 'V_N') then
begin
for
select
T.codprod,
T.qtdprod,
p.kitstau
from
tab_item T
left join tab_vend TS on (TS.codvend = t.codvend)
left join tab_prod P on (P.codprod = t.codprod)
where
T.codvend =:codvend
into
:codprod, :qtdprod, :kit
do
begin
if (KIT = 'N' ) then
begin
update tab_prod set ESTPRODE = (ESTPRODE - :qtdprod)
where codprod =:codprod;
end
else
begin
for
select
i.intkite,
i.qtdikit
from
tab_ikit i
where
i.codprod =:codprod
into
:codprod1, :qtdprod1
do
update tab_prod set ESTPRODE = (ESTPRODE - (:qtdprod1 * :qtdprod ))
where codprod =:codprod1;
update tab_prod set ESTPRODE = (ESTPRODE - :qtdprod)
where codprod =:codprod;
end
end
end
ela faz um lop na tabela item e verefica se é um kit pra buscar em outra
if ( :OPE = 'V_N') then
begin
for
select
T.codprod,
T.qtdprod,
p.kitstau
from
tab_item T
left join tab_vend TS on (TS.codvend = t.codvend)
left join tab_prod P on (P.codprod = t.codprod)
where
T.codvend =:codvend
into
:codprod, :qtdprod, :kit
do
begin
if (KIT = 'N' ) then
begin
update tab_prod set ESTPRODE = (ESTPRODE - :qtdprod)
where codprod =:codprod;
end
else
begin
for
select
i.intkite,
i.qtdikit
from
tab_ikit i
where
i.codprod =:codprod
into
:codprod1, :qtdprod1
do
update tab_prod set ESTPRODE = (ESTPRODE - (:qtdprod1 * :qtdprod ))
where codprod =:codprod1;
update tab_prod set ESTPRODE = (ESTPRODE - :qtdprod)
where codprod =:codprod;
end
end
end
Marcos Cruz
Curtidas 0