Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting rounded Result on a Calculation

Status
Not open for further replies.

SamC

Programmer
Aug 22, 2002
24
DE
i've the following problem:

sometimes my ib-server gets in the state that the result of calculations are rounded.
stopping and restarting ib-server get's it out of this state.
after a recalculation the results are ok.

i do don't know why the ib server get's in this state.

is there anyone with the sam problem and can help?

greetings, sam
 
Just seen this post. Did you find a solution yet ? Did you mean that the results to the exact same calculation were different after re-starting the IB Server (sometimes it rounded the amount - sometimes not ?)

Opp.
 
thanks for your interest Oppenhiemer.

yes, the exact same calculation.

if in the 'state' every calculation is rounded until restart.
the calc is done in triggers.

the trigger:

...
as
declare variable u varchar(30);
begin
u=new.lusr;
if (new.pkz='F') then begin
new.gpreis=new.menge*new.epreis;
end else if (new.pkz='S') then begin
new.gpreis=new.menge*((new.epreis/60)*new.ae);
end
update TABLE_Y
set sapreis = (sapreis+new.gpreis),lusr=:u
where id = new.sauft_id;
end



as a workaround i use a scheduled restart of the ib-server task an execute the procedure update_TABLE_X.

the procedure:

CREATE PROCEDURE UPDATE_TABLE_X
AS
begin
update TABLE_X set pos=pos where pkz='F' and cast((menge*epreis) as numeric(9,2))<>gpreis;
update TABLE_X set pos=pos where pkz='S' and cast((menge*((epreis/60)*ae)) as numeric(9,2))<>gpreis;
end

in this proc i only update the field named 'POS' with it's value to fire the UPD trigger of TABLE_X. after the execution all values are correct.

greetings, sam
 
Well.. Im please you got a workaround for it Sam - I must admit, I have not tried doing any calc's in Stored procedures yet (I use Delphi to do all that stuff.)

Opp.

P.S That is weird though - maybe worth mentioning in the INterbase Newsgroups - see what they say.

 
hello oppenhiemer,

i've tried several IBNewsgroups - with no result.

i found out that this must happen after the daily 'FILE'-backup, because the last calculation on every work-day is correct and when i encounter the problem the first calculation of this work-day and then all following are incorrect.

this could be a problem of copying the db-file while ib-server is running. (but i'done this for many years with no probs)

no doubt but checking on, sam.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top