获取Coldfusion复杂对象错误但没有复杂的对象

0 coldfusion

我得到"复杂对象类型无法转换为简单值."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#
Run Code Online (Sandbox Code Playgroud)

Pet*_*ton 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" />
Run Code Online (Sandbox Code Playgroud)

请注意,除了cfqueryparam(通常应该用于所有动态变量,但尤其是客户端提供的变量),这两个变量已经url作用域,并且可能正确地确定变量的范围是修复(如果是locationId或operatorId)存在于其他范围内,作为非简单变量).