Reputation: 2303
I have a self-submitting form, whose data gets used in a cfquery after it is submitted. I'm having a problem when the user submits a decimal rather than an integer.
This is for tires sizes
<select>
...
<option value="19.0">R19</option>
<option value="19.5">R19.5</option>
...
</select>
Then if the form is submitted, the results are passed on to a cfquery to show results only for that size.
<cfif form.size gt 0 >
AND ts.decDiameter = <cfqueryparam cfsqltype="cf_sql_decimal" value="#form.size#" />
</cfif>
This works perfectly for whole numbers, but when I select 19.5, it brings me back the results for 20. It is rounding up. Something weird with the cfqueryparam. It is transforming the result into a numeric value, but it is rounding it up to the next integer.
Upvotes: 3
Views: 508
Reputation: 10473
You need to add the scale parameter.
<cfqueryparam cfsqltype="cf_sql_decimal" scale="2" value="#form.size#">
You can use this reference...
http://help.adobe.com/livedocs/coldfusion/8/htmldocs/help.html?content=Tags_p-q_18.html
Upvotes: 9