• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFPARAM from a Query

Explorer ,
Sep 05, 2006 Sep 05, 2006

Copy link to clipboard

Copied

Im trying to work out a percentage from a database!

Im new to coldfusion and with my small amount of knowledge i thought it might be possible this way!

A count query to select all the F from the STATUS field in the database, as below

<cfquery name="countFails" datasource="breeze">
SELECT COUNT(STATUS)
FROM PPS_TRANSCRIPTS JOIN PPS_PRINCIPALS ON PPS_TRANSCRIPTS.PRINCIPAL_ID = PPS_PRINCIPALS.PRINCIPAL_ID
WHERE NAME LIKE '#FORM.allNames#'
AND STATUS LIKE 'F'
</cfquery>

if i out put it i get the correct answer of 23, but i dont want to out put it i want to save it as a variable. So i put the following code in -

<cfparam name="fails" default="#STATUS.countFails#">

i just get -

Error Occurred While Processing Request
Element COUNTFAILS is undefined in STATUS.

Am i going the correct way of doing this?

Ta


TOPICS
Advanced techniques

Views

428

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 05, 2006 Sep 05, 2006
give count(status) an alias. Otherwise, I don't even think Ian's solution will work.

Also, your query will run faster if you change
status like 'F'
to
status = 'F'

Votes

Translate

Translate
LEGEND ,
Sep 05, 2006 Sep 05, 2006

Copy link to clipboard

Copied

Nope you are doing it the wrong way. It is query.column not column.query

<cfset fails = countFails.status>

I'm not sure why you are using cfparam, but if you need to use it, just
use countFails.status in the default parameter.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 05, 2006 Sep 05, 2006

Copy link to clipboard

Copied

LATEST
give count(status) an alias. Otherwise, I don't even think Ian's solution will work.

Also, your query will run faster if you change
status like 'F'
to
status = 'F'

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation