Skip to main content
December 8, 2010
Question

Simple Math in SQL Query or cfset

  • December 8, 2010
  • 1 reply
  • 1353 views

Calculated fields in the DB vs <cfset>?

It would seem simple, but:

ACCESS DB ;>(

CF9

IIS

<cfquery name="get_total" datasource="#Request.BaseDSN#">
SELECT SUM((current_charge+penalty)-credit) AS total
FROM moorings
WHERE mooring_ID = #URL.mooring_ID#
</cfquery>

<cfdump var="#total#"> 

Variable TOTAL is undefined?

or

<cfset subtotal = current_charge+penalty>

<cfset total = subtotal-credit>

Variable CURRENT_CHARGE is undefined?

Missing ',", (, #'s?

Thanks

This topic has been closed for replies.

1 reply

Inspiring
December 8, 2010

TOTAL is just a column in the recordset get_total.  You need to reference it as get_total.total.  get_total is the CF variable here.

--

Adam

December 8, 2010

Thanks for the quick response-

Using that query,

<cfdump var="#get_total.total#"> = [empty string]

Inspiring
December 8, 2010

Looks like your query either did not return any rows or returned 1 row with a null value in it.