epipko
05/27/2022, 4:28 PM<cfquery name="q1" datasource="#REQUEST.PROD#">
select return_id
from ecomm_returnly_temp
where return_id NOT IN (select return_id from ecomm_returnly)
order by return_id
</cfquery>
<cfif #q1.RecordCount# GT "0">
<cfloop query="q1">
<cfset return_id = #q1.return_id#>
<cfinclude template="returnly_api_get_return_by_id.cfm">
</cfloop>
</cfif>
If I convert query data into a list, it works just fine:
<cfset returns_list = "">
<cfquery name="q1" datasource="#REQUEST.PROD#">
select return_id
from ecomm_returnly_temp
where return_id NOT IN (select return_id from ecomm_returnly)
order by return_id
</cfquery>
<cfset returns_list = ValueList(q1.return_id,",")>
<cfif ListLen(returns_list)>
<cfloop list="#ListSort(returns_list,"Numeric","asc",",")#" index="return_id">
<cfinclude template="returnly_api_get_return_by_id.cfm">
</cfloop>
</cfif>
Jim Frankowski
05/27/2022, 4:36 PMepipko
05/27/2022, 4:39 PMJim Frankowski
05/27/2022, 4:45 PMepipko
05/27/2022, 5:02 PMAdam Cameron
"Element RETURN_ID is undefined in Q1."It will also be giving you a line number. Which is fairly critical to solving these sort of things (both for yourself, and when giving other people out of context code)
Adam Cameron
<cfset return_id = #q1.return_id#>
You already don't need to qualify the column reference with the query name in a query loop. What are you hoping to achieve with that?Adam Cameron
Adam Cameron
epipko
05/31/2022, 9:42 PM<cfset return_id = #q1.return_id#>
because <cfinclude ..> comes after that and I use return_id in API call to get return data for single return. At this point I am going to stick with loop over list as it works well. Thanks again.dawesi
08/13/2022, 9:45 PM<cfif q1.RecordCount><cfelse></cfif>
as 0 is false and everything above zero is truedawesi
08/13/2022, 9:48 PM<cfset return_id = #q1.return_id#>
two variables called return_id?? should be something like
<cfset this_return_id = #q1.return_id#>
or if template uses return_id, then alias sql with
SELECT return_id AS my_return_id
as you might have a collision there with names