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

session max from query

Guest
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

Hi i have the query below which is ok, but i need to have a default value for SESSION.year5, the problem i have is i need the default vale to be "MAX GetResults.MR.Season" not sure how to enter this into my code, do i add it to the cfparam default or efelse the session

<cfparam name="SESSION.TeamName5" type="string" default="">
<cfparam name="SESSION.Year5" type="string" default="">

<cfif isdefined ("FORM.Years")>
<cfset SESSION.Year5 = FORM.Years>
</cfif>

<cfquery name="GetResults" datasource="Cricket">
SELECT *
FROM matchresults MR

INNER JOIN
TeamNames TN
ON MR.TeamID = TN.ID

INNER JOIN
SeasonTable ST
ON MR.Season = ST.SeasonID

WHERE
0=0
<CFIF SESSION.TeamName5 IS NOT "">
AND
(MR.TeamID = '#SESSION.TeamName5#')</CFIF>
<CFIF SESSION.Year5 IS NOT "">
AND
(MR.Season = '#SESSION.Year5#')</CFIF>
</cfquery>
TOPICS
Advanced techniques

Views

354

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 ,
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

If you want to set the session variable to something based on a query result, you have to do so after you run the query. So it certainly won't be in cfparam.

How you code it depends on what you are trying to do. I notice that it changes if a form variable exists.

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
Guest
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

Ok many thanks

so could i do something like this after the query?


<cfif isdefined ("FORM.Years")>
<cfset SESSION.Year5 = FORM.Years>
<cfelse>
<cfset SESSION.Year5 = MAX GetResults.MR.Season>
</cfif>

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
Guest
Jul 06, 2006 Jul 06, 2006

Copy link to clipboard

Copied

Ok many thanks

so could i do something like this after the query?


<cfif isdefined ("FORM.Years")>
<cfset SESSION.Year5 = FORM.Years>
<cfelse>
<cfset SESSION.Year5 = MAX GetResults.MR.Season>
</cfif>

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 ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

The syntax is fine. The logic may or may not be, depending on what you want to do. If you step back from your code a bit and describe to yourself in simple English what you want to do, you can then convert that to code.

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
Guest
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

LATEST
Ok what i need is set session to form value if defined, if not defined set session to MAX GetResults.MR.Season

i have tried the code below but i get this error

Invalid CFML construct found on line 37 at column 29.
ColdFusion was looking at the following text:
GetResults.MR.Season

<cfif isdefined ("FORM.Years")>
<cfset SESSION.Year5 = FORM.Years>
<cfelse>
<cfset SESSION.Year5 = MAX GetResults.MR.Season>
</cfif>


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