>I was doing a simple SQL with SUMs and got a numeric overflow error at random intervals. The code was:
>
>SELECT sum(lineitem) as linetotal, sum(iif(taxable, lineitem, 0)) as taxtotal from MyTable into cursor MyCursor
>
>The problem was the sum(iif(taxable, lineitem,0)) which worked about 95% of the time and gave me the numeric overflow error the remaining times. I presume I have to set the size of the numeric field, as must be done with variable length character fields, but don't know how.
>
>All help gratefully accepted.
>
>TIA
>Barbara
It should work:
SELECT sum(lineitem)+000000000 as linetotal, ;
sum(iif(taxable, lineitem, 0))+000000000 as taxtotal from MyTable into cursor MyCursor
Add reasonable number of zeros.
The reason was that Foxpro allocates cursor field width (if AS clause used) based on first selected record.
Edward Pikman
Independent Consultant