2

我在 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">

4

1 回答 1

2

该问题可能与查询参数无关。执行语句最后一行的 Oracle 错误(通常是 where、group by 或 order by 子句)。如果您提供 ORA- 错误和您的表定义,那将有所帮助。

但该错误可能与查询参数无关。还有其他问题(连接中的相同列(例如,查询中两个表中的 ID 列)、缺少逗号等)。

编辑:

根据cfqueryparam帮助页面中的文本,您可能想尝试 CF_SQL_FLOAT 或 CF_SQL_DECIMAL,因为 CF_SQL_NUMERIC 似乎与 Oracle 没有直接关联。您也可以检查其他列。我不知道这是否能解释它,但我似乎记得在过去看到过这个。

于 2012-08-13T15:09:19.260 回答