简体   繁体   中英

How to change the field type of result set from SQL pass-through (SPT)?

I have a mysql table column defined as unit_price float(12,4) .

If I assign a value of 0.1234 , when I create a remote view with dbsetprop , I can retrieve 0.1234 with myview.unit_price .

However, when I use SQL pass-through (SPT) like this:

sqlexec(nHandle, "select * from table", "oResult")

the result of oResult.unit_price only shows 0.12 .

How can I ensure that I return the correct, full value?

Not having explicitly tried, you can do some simple math forcing to create larger precision, such as adding an additional column to your query... something like...

select *, unit_price * 1.00000 as UnitPrice5 from...

This will force the field to be computed to 5 decimal position and MIGHT actually change the result column to properly handle this forced decimal capacity. Then, you would use the "UnitPrice5" column instead of "unit_price"...

Don't know if that would be a big issue for you, but once it is in VFP, you have more control too.

The length of the decimal values are defined in your FoxPro settings. Go to Tools->Options->Regional and set the Decimal Digits to a higher value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM