By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 838 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

Rounding Problem in Stored Functions

P: 1
Hi Friends

I am having trouble with a function Round.This function returns different values in different scenarios.
This is what happens when value was directly passed

Query goes as follows

* Passing Value directly

zint numeric(12,0);

zint := Round((3000.00 / 1200),0);
return zint ;
end;'

Above Func return value 2 in zint

This is what happens when value is passed through a variable.
*Passing it through Variable.

Query goes as follows

zint numeric(12,0);
zproduct numeric(12,0);
begin
zproduct:=1000;
zproduct:=(zproduct * 3)/1200;
zint := Round(zproduct);
return zint ;
end;'

Above Func return value 3 in zint

Can anyone help me to know the difference between the two query?
Jan 19 '08 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Hi Friends

I am having trouble with a function Round.This function returns different values in different scenarios.
This is what happens when value was directly passed

Query goes as follows

* Passing Value directly

zint numeric(12,0);

zint := Round((3000.00 / 1200),0);
return zint ;
end;'

Above Func return value 2 in zint

This is what happens when value is passed through a variable.
*Passing it through Variable.

Query goes as follows

zint numeric(12,0);
zproduct numeric(12,0);
begin
zproduct:=1000;
zproduct:=(zproduct * 3)/1200;
zint := Round(zproduct);
return zint ;
end;'

Above Func return value 3 in zint

Can anyone help me to know the difference between the two query?
What postgres do you use? It works fine for me, the first function return 3 I've tested it.
Jan 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.