Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

testing for nullness 2

Status
Not open for further replies.

leadman

Programmer
Jun 11, 2001
177
US
Hi all,
I seem to have forgotten how to test if a query field has come up null - I tried this:

<cfif Not isNull(&quot;strName&quot;)>

and got an error because isNull isnt recognized coldfusion - how would i write this and what is a good online resource to quickly look this stuff up (i tried searching &quot;test for null&quot; at cfhub but came up empty)
 
<cfif IsDefined(&quot;varName&quot;) AND varName EQ &quot;&quot;> Sylvano
dsylvano@hotmail.com
 
ColdFusion converts NULL values from a Query to an empty string &quot;&quot;. So check to make sure the string isn't empty, you would do what WWebSpider recommended, only with one change.

<CFIF IsDefined(&quot;queryName.strName&quot;) AND queryName.strName NE &quot;&quot;>
or
<CFIF IsDefined(&quot;queryName.strName&quot;) AND queryName.strName IS NOT &quot;&quot;>

The way I prefer is to check the length of the string using this method.
<CFIF IsDefined(&quot;queryName.strName&quot;) AND Len(Trim(queryName.strName))>

You can remove the IsDefined() function if you're posotive that the variable exists, and shorten your <CFIF> statement.

<CFIF Len(Trim(queryName.strName))> - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top