Skip to main content
June 9, 2009
Question

cfstoredproc scope issue?

  • June 9, 2009
  • 1 reply
  • 2091 views

When i try to display

<tr><td id="smNormalText">Country: <strong><cfoutput>#list_all_country_sp_rst.county_name#</cfoutput></strong></td></tr>

i get empty value....it is not displaying Country value coming from procedure

Here is code

<cfstoredproc procedure="list_all_country_sp" datasource="#dsn#" username="#user#" password="#pass#" returncode="yes" debug="yes">

        <cfprocresult name="list_all_country_sp_rst">    

</cfstoredproc>

    <cfloop query="list_all_country_sp_rst">      

    <cfstoredproc procedure="list_all_state_sp" datasource="#dsn#" username="#user#" password="#pass#" returncode="yes" debug="yes">

            <cfprocresult name="list_all_state_sp_rst">

            <cfprocparam type="in" cfsqltype="CF_SQL_VARCHAR" variable="county_name_in" value="#list_all_country_sp_rst.county_name#"  null="no">

        </cfstoredproc>   

        <cfloop query="list_all_state_sp_rst">   

        <cfstoredproc procedure="name_count_sp" datasource="#dsn#" username="#user#" password="#pass#" returncode="yes" debug="yes">

            <cfprocparam type="in" cfsqltype="CF_SQL_VARCHAR" variable="state_name_in" value="#list_all_state_sp_rst.state_name#"  null="no">

            <cfprocresult name="name_count_sp_rst">

        </cfstoredproc>

        <cfif name_count_sp_rst.name_count neq '0'> 

        <tr><td id="smNormalText">Country: <strong><cfoutput>#list_all_country_sp_rst.county_name#</cfoutput></strong></td></tr>

<tr><td id="smNormalText">State: <strong><cfoutput>#list_all_state_sp_rst.state_name#</cfoutput></strong></td></tr>

</cfloop>

</cfloop>

This topic has been closed for replies.

1 reply

Participating Frequently
June 10, 2009

Try cfdump to see what values are returned from the stored procedure:


]]>

Mack

June 11, 2009

Tried with CFDump..

outer loop, cfdump is displaying value.

cfdump not displaying anything in inner loop...

Here is a Bug in CF. Please notfy to Adobe.

Can i get my money for finding bug?

Participating Frequently
June 11, 2009

I think this is the nested CFLOOP problem (in your inner CFLOOP you

access the outer loop variables). This is a known issue in ColdFusion,

please read the following blog entries:

- for CF7: http://www.bennadel.com/blog/322-Nesting-CFLoop-Tags-Of-The-SAME-Query-Hmmmm.htm

- for CF8 update:

http://www.bennadel.com/blog/322-Nesting-CFLoop-Tags-Of-The-SAME-Query-Hmmmm.htm

Mack