-
1. Re: Simple Math in SQL Query or cfset
Adam Cameron. Dec 8, 2010 9:02 AM (in response to sakonnetweb)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
-
2. Re: Simple Math in SQL Query or cfset
sakonnetweb Dec 8, 2010 9:11 AM (in response to Adam Cameron.)Thanks for the quick response-
Using that query,
<cfdump var="#get_total.total#"> = [empty string]
-
3. Re: Simple Math in SQL Query or cfset
Dan Bracuk Dec 8, 2010 11:27 AM (in response to sakonnetweb)Looks like your query either did not return any rows or returned 1 row with a null value in it.
-
4. Re: Simple Math in SQL Query or cfset
Andy Matthews Dec 8, 2010 5:51 PM (in response to Dan Bracuk)Run the query without using SUM to see what values are stored in the database:
<cfquery name="get_total" datasource="#Request.BaseDSN#">
SELECT current_charge, penalty, credit
FROM moorings
WHERE mooring_ID = #URL.mooring_ID#
</cfquery><cfoutput>
charge: #get_total.current_charge#<br />
penalty: #get_total.penalty#<br />
credit: #get_total.credit#<br />
</cfoutput>
or
<cfdump var="#get_total#">
Also, it's a good idea to get into the habit of using cfqueryparam in your SQL queries. It helps sanitize your inputs and prevents SQL injection attacks:
<cfquery name="get_total" datasource="#Request.BaseDSN#">
SELECT current_charge, penalty, credit
FROM moorings
WHERE mooring_ID = <cfqueryparam value="#URL.mooring_ID#" cfsqltype="cf_sql_integer">
</cfquery>



