使用cfquery cfqueryparam出现奇怪的ColdFusion 10错误

3
我正在使用ColdFusion 10 Update 23与MySQL数据库。当我在使用cfqueryparam的脚本中进行更改时,脚本会出现以下错误消息:“无法确定标记queryparam的属性值类型。”
这个脚本是完美的:
<cfquery name="i" datasource="tasktrack">
UPDATE qa_commitments
SET 
    commit_division = <cfqueryparam cfsqltype='cf_sql_integer' value='#trim(commit_division)#'/>,
    commit_source = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_source))#'/>,
    commit_title = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_title))#'/>,
    commit_responsibility = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_responsibility))#'/>,
    <cfif Len(commit_cause)>commit_cause = <cfqueryparam cfsqltype='cf_sql_varchar' value='#commit_cause#'/>
    <cfelse>commit_cause = NULL</cfif>,
    commit_comments = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(PreserveSingleQuotes(commit_comments)))#'/>,
    commit_issue_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_issue_date#'/>,
    commit_response_due_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_response_due_date#'/>,
    commit_response_compl_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_response_compl_date#'/>,
    commit_action_due_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_action_due_date#'/>
    <cfif IsDefined('commit_closeing_date')> ,commit_closeing_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_closeing_date#'/></cfif>
WHERE ID = #id# 

如果我打开脚本并添加任何内容(例如,回车、制表符、注释),保存脚本,就会出现上述错误。如果我从旧版本恢复脚本,它又可以正常工作了。我打开旧版本,在插入换行符后用Enter键保存,然后它又崩溃了。 真正奇怪的是,如果我完全删除cfqueryparam标签,脚本就可以再次工作。 每个使用此标签的脚本都会出现这种情况。 CF的最后更新是在2017年4月,有几个较新的脚本可以工作,除非我编辑它们。 我已经尝试了不同的编辑器,结果相同。 我已经搜索了很多,但没有结果。 请问有人能指导我正确的方向吗?

{btsdaf} - GThurmon
{btsdaf} - GThurmon
{btsdaf} - GThurmon
{btsdaf} - GThurmon
嗯...听起来好像是有特殊字符被插入进去了。你提到了McAfee - 你是否能直接从服务器获取文件的访问权限? - snackboy
显示剩余12条评论
2个回答

1
我无法告诉你为什么它坏了,但我可以告诉您我如何修复它。
<cfif>放在查询内部会导致数据库引擎无法缓存查询。因此,我会将它们移出来,并在查询中放置条件逻辑。
<cfquery name="i" datasource="tasktrack">
DECLARE @commit_clause varchar(40) = <cfqueryparam cfsqltype='cf_sql_varchar' value='#commit_cause#' null="#IIF(len(commit_clause)1, 0)#"/>
DECLARE @commit_closeing_date date = cfqueryparam cfsqltype='cf_sql_date' value='#commit_closeing_date#' null="#IIF(isDefined(Commit_closeing_date), 0, 1)#"/>.

UPDATE qa_commitments
SET 
    commit_division = <cfqueryparam cfsqltype='cf_sql_integer' value='#trim(commit_division)#'/>,
    commit_source = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_source))#'/>,
    commit_title = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_title))#'/>,
    commit_responsibility = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(commit_responsibility))#'/>,
    commit_cause = @commit_clause,
    commit_comments = <cfqueryparam cfsqltype='cf_sql_varchar' value='#ucase(trim(PreserveSingleQuotes(commit_comments)))#'/>,
    commit_issue_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_issue_date#'/>,
    commit_response_due_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_response_due_date#'/>,
    commit_response_compl_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_response_compl_date#'/>,
    commit_action_due_date = <cfqueryparam cfsqltype='cf_sql_date' value='#commit_action_due_date#'/>,
    commit_closeing_date = @commit_closeing_date
WHERE ID = #id# /* I would fix this too */
</cfquery>

离题

我建议使用实体。我真的不喜欢一遍又一遍地写这些东西。


0
我找到了问题所在,问题是McAfee scriptscan。我让IT人员关闭了它,现在脚本可以工作了。IT把问题归咎于旧版本的Windows Server 2008和它与McAfee Enterprise的兼容问题。感谢您提供的所有帮助。有人指导确实很有帮助。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接