我在 Coldfusion 中运行更新查询时遇到问题。我收到一条错误消息,提示 CFSQLTYPE CF_SQL_NUMERIC 的数据无效。我知道数据是数字的,因为我在错误之前输出它并且它是正确的。我像这样设置变量:
<cfset itemID = FORM.itemID * 1> <!--- The * 1 is to force a numeric operation, and
therefore a numeric datatype, and like I said, it outputs right. --->
<!--- This is the line (45) the error says is bad --->
WHERE itemid = <cfqueryparam value="#itemID#" cfsqltype="CF_SQL_NUMERIC">
发生的一件奇怪的事情是,如果我将 cfqueryparam 更改为 varchar,我仍然会得到同样的错误!!
WHERE itemid = <cfqueryparam value="#itemID#" cfsqltype="CF_SQL_VARCHAR">
更奇怪的是,当我完全取出 cfqueryparam 并使用一个数字时,会出现一个新错误,说 BEFORE (44) 行现在不好:
WHERE itemid = 20072 <!--- Changing to this produces a new error on the line before --->
<!--- Line 44, which is also using a cfqueryparam numeric. This new error is the same
as before, but on line 44 now instead of 45. --->
min_qty = <cfqueryparam value="#FORM.itemMinQuantity#" cfsqltype="CF_SQL_NUMERIC">
知道发生了什么吗?
编辑更多代码...
<cfquery name="qUpdateItem" datasource="#thedb#">
UPDATE items_something
SET
itemdesc = <cfqueryparam value="#FORM.itemDescription#" cfsqltype="CF_SQL_VARCHAR">,
room = <cfqueryparam value="#FORM.itemRoom#" cfsqltype="CF_SQL_VARCHAR">,
value = <cfqueryparam value="#FORM.itemValue#" cfsqltype="CF_SQL_NUMERIC">,
categoryid = <cfqueryparam value="#FORM.categoryID#" cfsqltype="CF_SQL_NUMERIC">,
keywords = <cfqueryparam value="#FORM.itemKeywords#" cfsqltype="CF_SQL_VARCHAR">,
manufact = <cfqueryparam value="#FORM.itemManufacturer#" cfsqltype="CF_SQL_VARCHAR">,
partno = <cfqueryparam value="#FORM.itemPartNumber#" cfsqltype="CF_SQL_VARCHAR">,
itemtitle = <cfqueryparam value="#FORM.itemTitle#" cfsqltype="CF_SQL_VARCHAR">,
qty = <cfqueryparam value="#FORM.itemQty#" cfsqltype="CF_SQL_NUMERIC">,
assembly_draw_no = <cfqueryparam value="#FORM.itemAssemblyDrawingNo#" cfsqltype="CF_SQL_NUMERIC">,
bin = <cfqueryparam value="#FORM.itemBin#" cfsqltype="CF_SQL_VARCHAR">,
shelf = <cfqueryparam value="#FORM.itemShelf#" cfsqltype="CF_SQL_VARCHAR">,
min_qty = <cfqueryparam value="#FORM.itemMinQuantity#" cfsqltype="CF_SQL_NUMERIC">
WHERE itemid = <cfqueryparam value="#itemID#" cfsqltype="CF_SQL_NUMERIC">