问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/33807673/cfdump-different-for-cfquery-vs-cfstoredproc