/t5/coldfusion-discussions/assigning-a-variable-a-null-value/td-p/893102Dec 03, 2008
Dec 03, 2008
Copy link to clipboard
Copied
Hi all. I've got a loop that queries a query outside of the
loop. The problem is, the query may get defined, and it may not.
But if it gets defined, how do I undefine it for the next loop
iteration. Here's some code to wrap your head around it (edited for
brevity).
<cfloop>
<cfset queryValue = possibleEmptyString >
<cfset queryName = QueryNew()> <!--- this ensures
that queryName is always defined, and is always a query --->
<cfif Len(queryValue)>
<cfquery name="queryName" dbtype="query">
select * from something
</cfquery>
</cfif>
/t5/coldfusion-discussions/assigning-a-variable-a-null-value/m-p/893104#M82128Dec 04, 2008
Dec 04, 2008
Copy link to clipboard
Copied
Thanks Dan. But, that won't quite solve my problem.
The problem is that once it becomes a query, I can't reset it
back to a String value because I've already turned it into a
complex type so IsQuery() it will always return true.
not sure how using a try/catch will solve it either. Am I
missing something here?
Thanks for your reply, I appreciate the attentiont to this
issue.
<cfloop>
<cfset queryValue = possibleEmptyString >
<cfset queryName = QueryNew()> <!--- this ensures
that queryName is always defined, and is always a query --->
<cfif Len(queryValue)>
<cfquery name="queryName" dbtype="query">
select * from something
</cfquery>
</cfif>