title: ColdFusion - Variable variableName is undefined
body: <p>In my <code>cfoutput</code> tag, I've set a variable that stores the name of a customer returned from a query. Then I use that variable in the <code>WHERE</code> clause in <code>cfquery</code> tag to retrieve the customer info. But I'm getting the error <code>Variable CUSTOMER is undefined</code> under certain search criteria when the form is submitted. I think the error occurs when CUSTOMER variable is null. I've tried various options in the following Where clause such as <code>where Customers.CustomerName = #IIF(isDefined('Form.CUSTOMER'),de(Form.CUSTOMER),de(''))#</code> but I still get the same error. I'm using <code>SQL Server 2012</code> on the backend. Note that I cannot use <code>cfparam</code> inside <code>cfoutput</code>: </p>
  
  <pre><code>&lt;cfoutput query="qry_customers"&gt;
  &lt;cfset  CUSTOMER = #CUSTOMER#&gt;
  &lt;/cfoutput&gt;
  &lt;cfquery name="get_customers" datasource="#request.dsn_name#"&gt;
           SELECT * from Customers
           where Customers.CustomerName = '#CUSTOMER#'
  &lt;/cfquery&gt;
  </code></pre>
  
  <p><strong>UPDATE</strong> The error occurs in the <code>WHERE</code> clause in the <code>cfquery</code> tag below. And it occurs <code>only when</code> select statement in the cfquery tag  does not return any records. The CF error shows the line # of the error to be the line where the WHERE clause is.</p>