RHP*_*HPT 1 t-sql coldfusion cfquery cfstoredproc coldfusion-8
当我执行存储过程通过时cfstoredproc,我得到的结果不同于调用存储过程通过cfquery.我正在向每个调用传递相同的确切参数值.而且,当我在SQL Studio中运行存储过程时,我得到了正确的结果(与cfquery相同).
这是cfstoredproc电话
<cfstoredproc datasource="#request.mainDSN#" debug="#request.debug#" procedure="rankingresults">
<cfprocparam type="in" value="8652" CFSQLType="CF_SQL_INTEGER">
<cfprocparam type="in" value="50" CFSQLType="CF_SQL_INTEGER">
<cfprocparam type="in" value="53" CFSQLType="CF_SQL_INTEGER">
<cfprocresult name="local.listing">
</cfstoredproc>
Run Code Online (Sandbox Code Playgroud)
这是cfquery电话
<cfquery datasource="#request.mainDSN#" name="rankings">
EXEC rankingresults
@CityZipId = 8652,
@distance = 50,
@sic = 53
</cfquery>
Run Code Online (Sandbox Code Playgroud)
结果完全不同.它甚至都不是很接近.我已经被我的头撞了几个小时了,我无法弄清楚它为什么要做它正在做的事情.
UPDATE
存储的proc很大(我继承了一个),所以我不打算将它全部粘贴在这里:http://pastebin.com/EtufPWXf
Lei*_*igh 12
(来自评论)
看起来它确实有可选参数.因此,您的cfstoredproc电话可能无法传递您认为的值.根据订单,它看起来实际上传递的值为:@CityZipID, @Sic, @lastRank.正如Dan所提到的(我暗示过),cfstoredproc使用位置表示法来表示参数(不推荐使用@dbVarName).您需要以正确的顺序提供所有参数值.
更新:
FWIW,如果你创建一个shell过程,你会看到cfstoredproc和cfquery实际上是用不同的参数/值调用过程.(见下文).
如果你调用没有@Dan建议的命名参数的过程,你肯定会看到结果的差异exec rankingresults 8652, 50, 53.(我知道你说"没有变化",但你的测试可能只是一个错误).
CFSTOREDPROC
@ATTRCODES|@CITYZIPID|@DISTANCE|@HASURL |@ISFEATURED |@LASTRANK|@PHOTOCOUNT|@REVIEWCOUNT |@SIC|@SICBUDGETIDS
(nothing)| 8652| (nothing)| (nothing)| (nothing)| 53| (nothing)| (nothing)| 50| (nothing)
Run Code Online (Sandbox Code Playgroud)
CFQUERY
@ATTRCODES|@CITYZIPID|@DISTANCE|@HASURL |@ISFEATURED |@LASTRANK|@PHOTOCOUNT|@REVIEWCOUNT |@SIC|@SICBUDGETIDS
(nothing)| 8652| 50| (nothing)| (nothing)| 0| (nothing)| (nothing)| 53| (nothing)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
651 次 |
| 最近记录: |