I have a <cfquery> that outputs 3 columns (ct_pass (integer), ct_fail (integer), notes (varchar)). Seems as if it should be a simple matter to output the results to an array, then reference that array by row number and column number… but NOT. I’ve tried using code from several Google queries on “coldfusion, query, array”, but to no avail.
How should I populate the results of a <cfquery> into an array?
How do I then reference subsequent items within that array?
OR… Is there a way for me to reference <cfquery> results directly (by row and column)?
OK, this does output the given column and row. When I try to reference the given column and row within <cfset> though, I get the error “[Table (rows N columns … ] is not indexable by 1”. Here’s what I’m trying to do:
I have tried surrounding the expression with quote marks and also using the evaluate() function; still, no success. Interestingly enough, when I surround the expression in quotes AND use evaluate()…
“[Table (rows N columns … ] is not indexable by 1”. Here’s what I’m trying to do:
That usually means one or more of the column names you’re using can’t be found. But looking at your code, are you trying to calculate the total passed and failed for each record? Which db are you using? Because you can probably do that in your SQL OR in a QoQ. Assuming the fields are numeric, something like
<cfquery name=“traceResults” dbtype=“query”>
SELECT ct_pass, ct_fail, notes_trans, ct_pass + ct_fail AS TotalPassFail
FROM traceResults
</cfquery>