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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set Rounding off 1

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
Hi:

I am debugging some code that is rounding off values like 49.16 to 49.20 etc.

Doesn't make any sense but
Select ......,nvl(view1.total) as amnt
LEFT OUTER JOIN view1;
ON table1.key= view1.key;
group by table1.key into table tmpTable
nvl() was causing the problem.

I took the nvl() out and that fixed the problem. Now i just have (view1.total) as amnt. In view1 the value is 49.16 but after I do the select w/ nvl() I get 49.20

Any ideas why? Is there a function to turn rounding off?

Thanks
 
What error did you get? NVL has to be given 2 parameters.

Stewart
 
Sorry about that. I have nvl(view1.total, 0.00) as amnt.
I didn't get any errors except for the rounding problem I mentioned above.
 
Try making that:
nvl(view1.total, 00000000.00) as amnt

That is, since VFP sets computed field widths based on the first record it evaluates, if it was .Null. then the field would only be 4 characters wide. Therefore, 49.2 is as much information as could be stored!

Note: Feel free to adjust the number of zeros based on your expected data.

Rick
 
HI

I stick to Ricks suggestion. But I would put it in another way.

Select ......, NTOM(NVL(view1.total,0)) AS amnt

The reason is that view1.total can have a single digit or two digit result or could even be different digits while subseqent SQL selections could have different lengths.

NTOM() function will fix it to treat the column as currency type.
:)

ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top