sqlcoldfusionnullcfmlcfquery

Query null values


I have the column deletedTime in my instances table. Now I want to check in ColdFusion if the value is null. There is only one record to be printed out with the query. IsNull(test) is returning the correct value, but IsNull(searchForDeletedInstances.deletedTime) returns false but the value is in the datatable null..

<cfquery datasource="hostmanager" name="searchForDeletedInstances">
SELECT deletedTime
FROM instances
WHERE instanceId = <cfqueryparam value="#instanceId#" 
cfsqltype="CF_SQL_NVARCHAR">
</cfquery>

<cfloop query="searchForDeletedInstances">
    <cfset test= #deletedTime#>
</cfloop>

<cfreturn IsNull(test)>
<cfreturn IsNull(searchForDeletedInstances.deletedTime)>

Solution

  • Null values from a query come back as empty strings. Test for IsDate() instead. You can always use cfdump to show the contents of your query so you can see the data and data types returned.