0

我收到“无法将复杂对象类型转换为简单值。” locationId 和/或 operatorId 是通过 url 发送的,并且始终是一个简单的数字('304')。这是查询的代码:

select  *
from  table1, table2
where table1.u_construct_id(+)=table2.u_construct_id  
and table1.LOCATION_ID  = #locationId#
and   table1.OPERATOR_ID = #operatorId#
4

2 回答 2

8

完整的错误详细信息是什么?它是专门指向查询,还是仅仅指向查询附近的一条线,这导致您假设查询有问题。

(到目前为止,您发布的内容中没有任何内容表明这是一个查询问题。)

在任何情况下,您的查询目前都可能受到 SQL 注入,应更改为:

select  *
from  table1, table2
where table1.u_construct_id (+)= table2.u_construct_id  
and table1.LOCATION_ID = <cfqueryparam value="#url.locationId#" cfsqltype="cf_sql_integer" />
and table1.OPERATOR_ID = <cfqueryparam value="#url.operatorId#" cfsqltype="cf_sql_integer" />

请注意,除了 cfqueryparam(通常应用于所有动态变量,尤其是客户端提供的变量)之外,这两个变量已被确定url范围,并且很可能正确地确定变量的范围是解决方法(如果 locationId 或 operatorId存在于其他范围内,作为非简单变量)。

于 2012-06-25T21:58:46.637 回答
-3

感谢所有的帮助,但答案是必须重命名 operatorId。不知道为什么会这样,但怀疑 CF 将其视为保留条款。

于 2012-06-26T14:04:19.560 回答