In a coldfusion variable, NULL becomes an empty string. So your CFIF statement could read...
<cfif checkInvoice.invoiceno is not "" .....
or some people feel this will run faster.. check to see if there is any length to the value
<cfif len(checkInvoice.invoiceno
or this is equivalent...
<cfif len(checkInvoice.invoiceno
Here's the code:
<cfif len(checkInvoice.invoiceno
<cfset lcerror='<li class="error">Quotation-#a
<cfelse>
<cfquery name="qry_deletequotation"
DELETE from quotation
WHERE quotation_no = <cfqueryparam cfsqltype="cf_sql_varchar"
AND invoiceno is NULL <!---- as a failsafe, you can check during your delete ----->
</cfquery>
<cfset lcerror ='<li>Quotation - #attributes.code# has been deleted.</li>'>
</cfif>
By the way, try using cfthrow with cftry and cfcatch for error handling. Less code and handles any problem, not just the one you specify.
Gary
Main Topics
Browse All Topics





by: danrosenthalPosted on 2006-07-31 at 10:35:28ID: 17217509
I believe Coldfusion treats NULL values in query results as if they were no value (""), so in order to distinguish try a query like this:
"> value="#attributes.code#">
<cfquery name="checkInvoice" datasource="#mydatasource#
SELECT CASE WHEN invoiceno IS NULL then 'NULL' ELSE invoiceno END As invoiceno
from quotation
where quotation_no = <cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>