CFDUMP对于CFQUERY与CFSTOREDPROC不同 [英] CFDUMP different for CFQUERY vs CFSTOREDPROC

查看:293
本文介绍了CFDUMP对于CFQUERY与CFSTOREDPROC不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:



我有一个sproc,我用两种方式调用(cfquery和cfstoredproc),然后转储结果集。我在两种情况下都传递相同的参数,并且sproc为这个测试返回一个简单的硬编码结果。当我转储的结果,
我可以看到实际的查询SQL在cfquery调用,但不是在cfstoredproc调用。我想使用cfstoredproc版本,但希望能够像CFQUERY一样获取转储的SQL属性。



(是的,我知道有东西不同的方式CF准备语句等,我想知道确切的什么。)



CF代码: >

 < cfstoredproc datasource =tcprocedure =sp_dumptest> 
< cfprocparam type =indbvarname =@ arg1cfsqltype =CF_SQL_VARCHARvalue =1>
<!--- Out variable --->
< cfprocresult name =out1>
< / cfstoredproc>
< cfdump var =#out1#label =with cfstoredproc>

< cfquery name =out2datasource =tc>
{call sp_dumptest(1)}
< / cfquery>
< cfdump var =#out2#label =with cfquery>

输出





(在Adam回答后编辑) b

我试过添加一个result属性和一个fetchclientInfo,但它仍然不会给出实际的SQL。这是转储RESULT变量时转储的。

 < cfstoredproc datasource =Timecurrent
procedure = sp_dumptest
result =rsx
debug =true
fetchClientInfo =yes>
< cfprocparam type =indbvarname =@ arg1cfsqltype =CF_SQL_VARCHARvalue =1>
<!--- Out variable --->
< cfprocresult name =out1>
< / cfstoredproc>
< cfdump var =#rsx#label =with cfstoredproc>



环境:




  • Coldfusion 11,0,05,293506

  • SQL Server 2014


解决方案

正如Dave所说:



在第一个例子中,你只转储由 out 过程。



在第二个示例中,您将转储整个< cfquery> 调用,其中包括结果,以及传递给JDBC和各种其他位和块的SQL语句和参数。



如果你给你的< cfstoredproc> 调用结果属性,并转储 code> out?你不应该期望看到相同的元数据 - 它仍然是苹果和橘子 - 但它更可能有更多的细节。


Problem:

I have a sproc which I am calling in 2 ways (cfquery and cfstoredproc) and then dumping the resultsets. I am passing in the same argument in both cases and the sproc returns a trivial hard-coded result for this test. When i dump the results, I can see the actual query SQL in the cfquery call but not in the cfstoredproc call.Why? I would like to use the cfstoredproc version but want the ability to get the SQL attribute of the dump like in CFQUERY.

(Yes, I know there is something different in the way CF prepares the statement etc, I want to know exactly what.)

CF Code:

<cfstoredproc datasource="tc" procedure="sp_dumptest" >
    <cfprocparam type="in" dbvarname="@arg1" cfsqltype="CF_SQL_VARCHAR" value="1"  >
    <!--- Out variable --->
    <cfprocresult name="out1">
</cfstoredproc>
<cfdump var="#out1#" label="with cfstoredproc">

<cfquery name="out2" datasource="tc" >
{call sp_dumptest (1) }
</cfquery>
<cfdump var="#out2#" label="with cfquery">

Output:

(EDIT after Adam's answer)

I tried adding a result attribute and a fetchclientInfo, but it still wont give the actual SQL. Here is what is dumped when I dump the RESULT variable.

<cfstoredproc   datasource="Timecurrent" 
                procedure="sp_dumptest" 
                result="rsx" 
                debug="true" 
                fetchClientInfo="yes">
    <cfprocparam type="in" dbvarname="@arg1" cfsqltype="CF_SQL_VARCHAR" value="1"  >
    <!--- Out variable --->
    <cfprocresult name="out1">
</cfstoredproc>
<cfdump var="#rsx#" label="with cfstoredproc">

Environment:

  • Coldfusion 11,0,05,293506
  • SQL Server 2014

解决方案

As Dave said: you're comparing apples with oranges.

In the first example you are dumping out just the value of the out param returned by the proc. You'd only expect to see the value in there.

In the second example you are dumping the result of an entire <cfquery> call, which includes the result, as well as the SQL statement and params that were passed to JDBC and various other bits and bobs.

What happens if you give your <cfstoredproc> call a result attribute, and dump that out? You ought not expect to see the same sort of metadata - it's still apples and oranges - but it would be more likely to have additional details.

这篇关于CFDUMP对于CFQUERY与CFSTOREDPROC不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆