Question
correct syntax to check if return value is NULL inside Cffunction
Hi,
Can someone tell me how to check for a Null return value inside a cffunction?. Here's my code:
<cffunction name="getNewAgreementId" access="public" returntype="numeric" hint="Returns new ID." output="false">
<cfset newAgreementId=0>
<cfquery name="getLastAgreementId" datasource="#application.DSN#">
SELECT MAX(Agreement_Id) AS LastAgreementId
FROM Agreements
</cfquery>
<cfif getLastAgreementId.recordcount EQ 0 OR getLastAgreementId.LastAgreementId IS NULL>
<cfset newAgreementId=1>
<cfelse>
<cfset newAgreementId = getLastAgreementId.LastAgreementId + 1>
</cfif>
<cfreturn newAgreementId>
</cffunction>
The result of the cfquery is null.
Getting an error:
Variable NULL is undefined.
Can someone tell me how to check for a Null return value inside a cffunction?. Here's my code:
<cffunction name="getNewAgreementId" access="public" returntype="numeric" hint="Returns new ID." output="false">
<cfset newAgreementId=0>
<cfquery name="getLastAgreementId" datasource="#application.DSN#">
SELECT MAX(Agreement_Id) AS LastAgreementId
FROM Agreements
</cfquery>
<cfif getLastAgreementId.recordcount EQ 0 OR getLastAgreementId.LastAgreementId IS NULL>
<cfset newAgreementId=1>
<cfelse>
<cfset newAgreementId = getLastAgreementId.LastAgreementId + 1>
</cfif>
<cfreturn newAgreementId>
</cffunction>
The result of the cfquery is null.
Getting an error:
Variable NULL is undefined.
