Skip to main content
Inspiring
April 7, 2008
Question

Stange Cfquery NULL Error:

  • April 7, 2008
  • 2 replies
  • 683 views
I was working on the project when i came to a sudden problem, Where i was running into an error.

The error was sometimes appearing and sometimes not so i just tries to use th IsNull UDF from cflib library but still error persists:

here is the error: i recieve:

The system has attempted to use an undefined value, which usually
indicates a programming error, either in your code or some system
code.

Null Pointers are another name for undefined values.


and this was my query that where i used iSnull and Still getting the error:

<cfquery name="qGetArticleInfo" datasource="#Request.ConsultantTrackSiteDSN#">
SELECT SiteSections_LOOKUP.SiteSectionName, SiteSections_LOOKUP.SiteSection_ID, Articles.ImageFileName, Articles.Content, Articles.CallOut, Articles.Teaser, Articles.Title, Articles.dtStartDate, Articles.SubTitle, Articles.Article_ID, Articles.lColumnLengths, Articles.iCalloutWidth, Articles.ImageHeight, Articles.ImageWidth, Articles.bPDFArticle, Articles.PDFFileName, Articles.SmallImageFileName, Articles.SmallImageWidth, Articles.SmallImageHeight, Articles.SmallImageOriginalFileName
FROM SiteSections_LOOKUP INNER JOIN Articles ON SiteSections_LOOKUP.SiteSection_ID = Articles.SiteSection_ID
WHERE Articles.bDeleted = 0
<cfif IsNull(IsDefined("Attributes.Article_ID"))>
AND Articles.Article_ID = #Attributes.Article_ID#
<cfelseif IsNull(IsDefined("Attributes.SiteSection_ID"))>
AND Articles.bActive <> 0 AND Articles.SiteSection_ID = #Attributes.SiteSection_ID# AND Articles.dtStartDate <= #CreateODBCDate(Now())#
</cfif>
ORDER BY Articles.dtStartDate DESC, Articles.Title
</cfquery>


i tried a lot but in vain can anybody help in this instance..
    This topic has been closed for replies.

    2 replies

    Inspiring
    April 8, 2008
    There is no such thing as a NULL in ColdFusion, if you are using some Java that can return NULLs then it will not create the variable at all, and if it already existed it will now not exist.

    I do not see how the code you are showing us can have a null pointer exception, I suggest you step through the code line by line cfdumping what you have until you get the correct line number of the error.
    Participating Frequently
    April 8, 2008
    Does something like this work?

    <cfif IsDefined("Attributes.Article_ID") AND Attributes.Article_ID NEQ "">
    AND Articles.Article_ID = #Attributes.Article_ID#
    <cfelseif IsDefined("Attributes.SiteSection_ID") AND Attributes.SiteSection_ID NEQ "")>
    AND Articles.bActive <> 0
    AND Articles.SiteSection_ID = #Attributes.SiteSection_ID#
    AND Articles.dtStartDate <= #CreateODBCDate(Now())#
    </cfif>

    Phil
    Inspiring
    April 7, 2008
    check how you are using isnull() udf and how it actually should be used.

    some pointers:
    isdefined() returns either TRUE or FALSE
    isnull() udf returns either TRUE or FALSE

    see your mistakes?

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    April 7, 2008
    i changed a bit a code but still no sucees, here is my updated code:

    <cfquery name="qGetArticleInfo" datasource="#Request.ConsultantTrackSiteDSN#">
    SELECT SiteSections_LOOKUP.SiteSectionName, SiteSections_LOOKUP.SiteSection_ID, Articles.ImageFileName, Articles.Content, Articles.CallOut, Articles.Teaser, Articles.Title, Articles.dtStartDate, Articles.SubTitle, Articles.Article_ID, Articles.lColumnLengths, Articles.iCalloutWidth, Articles.ImageHeight, Articles.ImageWidth, Articles.bPDFArticle, Articles.PDFFileName, Articles.SmallImageFileName, Articles.SmallImageWidth, Articles.SmallImageHeight, Articles.SmallImageOriginalFileName
    FROM SiteSections_LOOKUP INNER JOIN Articles ON SiteSections_LOOKUP.SiteSection_ID = Articles.SiteSection_ID
    WHERE Articles.bDeleted = 0
    <cfif IsNull("Attributes.Article_ID")>
    AND Articles.Article_ID = #Attributes.Article_ID#
    <cfelseif IsNull("Attributes.SiteSection_ID")>
    AND Articles.bActive <> 0 AND Articles.SiteSection_ID = #Attributes.SiteSection_ID# AND Articles.dtStartDate <= #CreateODBCDate(Now())#
    </cfif>
    ORDER BY Articles.dtStartDate DESC, Articles.Title
    </cfquery>

    but if remove th Isnull, and use only isdefined, then error still persists, no knowing what is going wrong here..