Subject | Re: message length error ... |
---|---|
Author | Michael Vilhelmsen |
Post date | 2008-04-15T09:15:29Z |
> That sounds like an attempt to do a SELECT from an executable SP.Sorry Helen - You could be rigth here.
I really should read what people are written. Not what I think they
are writting.
I do have a trigger, that is doing this:
BEGIN
if (NEW.AntalStk<>OLD.AntalStk) then
begin
Execute Procedure BEREGN_GNSNTLAGER(
NEW.AntalStk,
OLD.AntalStk,
NEW.Beh_KostPris,
OLD.Beh_KostPris,
NEW.Beh_Salgspris,
OLD.Beh_Salgspris,
NEW.Beh_SalgsprisMOms,
OLD.Beh_SalgsprisMoms,
NEW.SidsteBev,
OLD.SidsteBev,
NEW.GnSntLager
)
RETURNING_VALUES new.GnSntLager;
end
END
The procedure is defined as this:
/*
Denne procedure beregner Gennemsnits lageret for tabeller generelt.
*/
Declare Variable gnLager Numeric(15,2);
Declare Variable AbsLagerAntal Numeric(15,2);
Declare Variable Lager1 Numeric(15,2);
Declare Variable LAger2 Numeric(15,2);
Declare Variable AbsBeh_KostPris Numeric(15,2);
Declare Variable DageTal integer;
Declare Variable AbsStk Numeric(15,2);
Declare Variable AbsKpr Numeric(15,2);
Declare Variable AbsSpr Numeric(15,2);
Declare Variable AbsMoms Numeric(15,2);
Declare Variable SprKprForhold Numeric(15,2);
begin
IF (OldSTK<> NewSTK) THEN
BEGIN
/*Stk, Kpr, Spr og Moms ændringer*/
AbsStk =(NewSTK - OldSTK);
AbsKpr =(NewKPR - OldKPR);
AbsSpr =(NewSPR - OldSPR);
AbsMoms =(NewMoms - OldMoms);
/*Spr uden moms*/
AbsSpr = AbsSpr - AbsMoms;
/*Kpr per stk*/
if (AbsStk<>0) then
begin
AbsKpr = AbsKpr / AbsStk;
end
/*Abs Kpr per stk*/
if (AbsKpr>0) then
begin
AbsKpr = AbsKpr;
end
else
begin
AbsKpr = AbsKpr * -1;
end
/*Spr per stk*/
if (AbsStk<>0) then
begin
AbsSpr = AbsSpr / AbsStk;
end
/*Abs Spr per stk*/
if (AbsSpr>0) then
begin
AbsSpr = AbsSpr;
end
else
begin
AbsSpr = AbsSpr * -1;
end
/*Spr Kpr Forhold*/
if (AbsSpr<>0) then
begin
SprKprForhold = AbsKpr / AbsSpr;
end
else
begin
SprKprForhold = 100;
end
/*Spr må ikke kunne gå op i Kpr mere end maks 10 gange*/
if (SprKprForhold<=10) then
begin
/*Abs nyt stk antal*/
if (NewSTK>0) then
begin
AbsLagerAntal=NewSTK;
end
else
begin
AbsLagerAntal=NewSTK*-1;
end
/*Abs nyt kostpris*/
if (NewKPR>0) then
begin
AbsBeh_KostPris=NewKPR;
end
else
begin
AbsBeh_KostPris=NewKPR*-1;
end
IF (NewGnSntLager=0) THEN
BEGIN
gnLager = AbsBeh_KostPris / 2;
END
else
begin
gnlager = newgnsntlager;
end
DageTal = (NewSidsteBev-OldSidsteBev);
if (DageTal>364) then DageTal=364;
if (dagetal>0) then
begin
lager1 = gnlager * (365-dagetal);
if (OldKPR>0) then
begin
lager2 = OldKPR * dagetal;
end
else
begin
lager2 = 0;
end
gnLager = (Lager1+Lager2) / 365;
end
Lager1 = gnLager * 364;
if (NewKPR>0) then
begin
lager2 = NewKPR;
end
else
begin
lager2 = 0;
end
gnLager = (lager1 + lager2) / 365;
GnSntLager = GnLAger;
Suspend;
end
else
begin
if (NewGnSntLager=0) then
GnSntLager=1;
else
GnSntLager=NewGnSntLager;
Suspend;
end
END
else
begin
GnSntLager=NewGnSntLager;
Suspend;
end
end
Those this "ring any bells" by you ?
Regards
Micheal