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

Coldfusion 2016

Community Beginner ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

I am running a Coldfusion application for over 10 years and just upgraded to coldfusion 2016.  Now I am getting strange results.  I have a query that uses values from another query and it says the first query is not defined.  I can get it to work sometimes if I do a cfoutput first but not always.  Also, if I print a value from the first query multilple times, the first time in may be blank and the second time it returns the value.  If I do it 4 times, every other output is correct.  This only starting happening with the latest release.

Views

1.2K

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
Guide ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

You're going to have to provide more details for anyone to try to assist you.  Can you provide the code for the queries in question?  And if the queries are inside a function, the whole function.  It sounds like the code might be doing some stuff asynchronously, but it's hard to tell how without some code to look at.

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
Community Beginner ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

Below is the query and the output.  However, just running this query by itself will work.  It's when you have it as part of a larger file.  I have simular errors in other places that work it I put the <cfoutput></cfoutput> near the code that errors.  This fixes it sometimes but not all.  I should not have to do this.  The code worked great in Coldfusion11 and just stopped when I upgraded to Coldfusion12.

<cfquery name="getHazUserInfo" datasource="#Application.DSN#">

SELECT *

FROM tblusers

WHERE ID = <cfqueryparam value="#ID#" cfsqltype="CF_SQL_INTEGER">

</cfquery>

  <cfdump var="#getHazUserInfo#" expand="no">

<cfoutput>FirstName1: #getHazUserInfo.FirstName#</cfoutput><br/>

<cfoutput>FirstName2: #getHazUserInfo.FirstName#</cfoutput><br/>

<cfoutput>FirstName3: #getHazUserInfo.FirstName#</cfoutput><br/>

OutputColdfusion_output.png

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
Guide ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

Are the three lines of code following the <cfdump> contrived, or real?  Without referencing the row number, each of those <cfoutput>...#getHazUserInfo.FirstName#</cfoutput> calls should be returning the exact same results (the first row of the query).

And just to rule it out, you don't have another variable/query in another scope that's named "getHazUserInfo"?

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
Community Beginner ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

No I was trying to show that even if I print the same 3 exact lines, expecting to see the same output, I am not.  And not the query is unique.  I've made a new example that I can put in full that works under coldfusion11 but not 2016.  I think the problem is that if I write a query then use: <cfoutput query=queryname> this causes a problem that should not.  Here is the code:

<table cellpadding="0" cellspacing="0" border="0">

  <tr>

  <td valign="top"><br/>

    <cfquery name="getHazUserInfo" datasource="#Application.DSN#">

   SELECT *

   FROM tblusers

   WHERE ID = 872

  </cfquery>

  <cfdump var="#getHazUserInfo#" expand="no">

  <cfoutput>getHazUserInfo1: #getHazUserInfo.ID#</cfoutput><br/>

  <cfoutput query="getHazUserInfo">

   <cfoutput>getHazUserInfo2: #getHazUserInfo.ID#</cfoutput><br/>

      <cfquery name="getHazUserSys" datasource="#Application.DSN#">

        select * from hazusersys

        WHERE HazUserSys.ID = <cfqueryparam value="#getHazUserInfo.ID#" cfsqltype="CF_SQL_INTEGER">

      </cfquery>

      <cfdump var="#getHazUserSys#" expand="no">

    </cfoutput>

    </td>

  </tr>

</table>

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

You're multiple nesting CFOUTPUTs, and then inserting a CFQUERY (bad form, IMHO) inside one of them.

Also, putting a CFDUMP inside a CFOUTPUT loop or a CFLOOP is just asking for resource overload trouble, depending upon how many records are being returned.

HTH,

^_^

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
Community Beginner ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

the cfdumps are just to see if the query worked they are not used in the final 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
LEGEND ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

Understood.. but even from a troubleshooting perspective, it can really bog down a server, even a dev or staging server.

V/r,

^_^

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
Community Beginner ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

You can take them out of the code and just leave the identical lines with the cfoutput and see that every other line prints the correct data and the other lines are blank:

      <cfoutput>getHazUserInfo2: #ID#</cfoutput><br/> <!---will show data--->

      <cfoutput>getHazUserInfo2: #ID#</cfoutput><br/> <!--- will be blank--->

      <cfoutput>getHazUserInfo2: #ID#</cfoutput><br/><!---will show data--->

      <cfoutput>getHazUserInfo2: #ID#</cfoutput><br/><!--- will be blank--->

if you have an odd number of the above lines, the query in the next line will work.

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

Try this:

<table cellpadding="0" cellspacing="0" border="0">

  <tr>

  <td valign="top"><br/>

    <cfquery name="getHazUserInfo" datasource="#Application.DSN#">

   SELECT *

   FROM tblusers

   WHERE ID = 872

  </cfquery>

  <cfdump var="#getHazUserInfo#" expand="no">

  <cfoutput>getHazUserInfo1: #getHazUserInfo.ID[1]#</cfoutput><br/>

  <cfoutput query="getHazUserInfo">

   getHazUserInfo2: #getHazUserInfo.ID#<br/>

      <cfquery name="getHazUserSys" datasource="#Application.DSN#">

        select * from hazusersys

        WHERE HazUserSys.ID = <cfqueryparam value="#getHazUserInfo.ID#" cfsqltype="CF_SQL_INTEGER">

      </cfquery>

      <cfdump var="#getHazUserSys#" expand="no">

    </cfoutput>

    </td>

  </tr>

</table>

See if this fixes anything.

HTH,

^_^

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
Community Beginner ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

So what you did is since I'm in the <cfoutput query="getHazUserSys" ...>

I do not need the <cfoutput>getHazUserInfo2: #getHazUserInfor.ID#</cfoutput>

I can just use: getHazUserInfo2: #getHazUserInfor.ID#

Is this the only change you made?

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

Pretty much, yes.  I also added an index to the record value outside of (prior to) the query cfoutput, so it would grab only the first iterative related value.

Nesting CFOUTPUTs can cause problems if they are not part of a "groupby" aggregation.

For example:  I have a project where I'm outputting the information for five events.  Without realizing it, I had accidentally placed CFOUTPUTs around the link for a Google Map to show location, nested inside the CFOUTPUT for the query.  So in Source View, all my links were showing (after the link to Google Maps) ?eid={first UUID}{second UUID}{third UUID}{fourth UUID}{fifth UUID}.

HTH,

^_^

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
Community Beginner ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

I understand the added an index to the record, however in my case it would only return 1 record since I have ID = 782.  But that wasn't the problem.

The problem was putting the <cfoutput> inside the <cfoutput query=...>

If I take out the <cfoutput> like you showed, my routine works.  Thanks for that.  However, even with it like I had it, it worked in ColdFusion11 and not in v2016.  I have over 200 places where I use <cfoutput query=...> and will have to check if I have nested <cfoutput> inside of them.  Since it worked in v11 it should work in v2016 without me having to do this.  I think it is a bug in v2016 and should be fixed.

You also talk about using:

Nesting CFOUTPUTs can cause problems if they are not part of a "groupby" aggregation.

How do you do that?

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

The groupby attribute is only used for things like:

Category 1

    SubCat 1

          SubSubCat 1

          SubSubCat 1

    SubCat 2

          SubSubCat 2

          SubSubCat 2

Category 2

    SubCat 1

          SubSubCat 1

          SubSubCat 1

    SubCat 2

          SubSubCat 2

For example:  A tabular display of State, City, and Municipalities.  You write the query to group by State, then City, then Municipality.  Then you would write the CFOUTPUT like:

<cfoutput query="myQuery" groupby="state">

    #myQuery.state#<br />

    <cfoutput grouby="city"><!--- From here out, you no longer need the query name --->

          #myQuery.city#<br />

          <cfoutput> <!--- Your last nest does not use groupby - using it can screw things up --->

              #myQuery.municipality#<br />

          </cfoutput>

    </cfoutput>

</cfoutput>

But this would not apply to your situation.

HTH,

^_^

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 ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

rpschwar27 wrote:

However, even with it like I had it, it worked in ColdFusion11 and not in v2016.

Perhaps, but it shouldn't have worked; if for no reason other than the groupby attribute.

I know it can sometimes be difficult to make sure you're not nesting tags (unless doing so in a very specific way, like groupby), but with the CFOUTPUT tag, once you've got your outer CFOUTPUT you should not be using nested CFOUTPUTs unless doing so with groupby.

If you really need to use internal CFOUTPUTs without the groupby attribute, then you should be using CFLOOP query="queryName" and then applying the internal CFOUTPUTs as needed.  CFLOOP does (now) have things like currentRow and recordCount, just like CFOUTPUT has had for a long time.

V/r,

^_^

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
Community Beginner ,
May 05, 2016 May 05, 2016

Copy link to clipboard

Copied

but since it did work, I would not expect a new version of coldfusion to cause me to have to rewrite code.  I'll check to see if I have any other nested <cfoutput> by making sure there are not two <cfoutput> together without having a </cfoutput> between them.

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
Advocate ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

You should always check to see if you code is compatible with the next version of Coldfusion.

A lot of changes are made and your code was bad practise. It was most likely caused by Adobe correctly fixing their product. They are only partially to blame for letting you get away with it for so long and not fixing it sooner.

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
Community Beginner ,
May 06, 2016 May 06, 2016

Copy link to clipboard

Copied

I have been talking to someone in Coldfusion support and they were finally able to reproduce the problem.  As soon as he was able to reproduce it, he sent me a jar file that fixed the problem.  He said that it would be in the next update which he had a beta copy of and sent it to me.  The beta update did not have the fix.  Hopefully it will be in the released version.  The jar file can be found;

ftp://cust-dl:$Poyr8Rfed@sjftp.adobe.com/ColdFusion/Alex

Place the fix in cfusion\lib\updates  and restart the service.

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 ,
May 09, 2016 May 09, 2016

Copy link to clipboard

Copied

Did the tech explain why your first query would sometimes show as undefined?

V/r,

^_^

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
Community Beginner ,
May 09, 2016 May 09, 2016

Copy link to clipboard

Copied

LATEST

No.  He did not give any explanation, just gave me the fix.

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 ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

Since the query is returning one record, I'm going to assume that you meant each <cfoutput> to display different columns of the record.

<cfoutput>

FirstName: #getHazUserInfo.FIRSTName#<br />

LastName: #getHazUserInfo.LASTName#<br />

Org: #getHazUserInfo.ORG#<br />

Email: #getHazUserInfo.EMAILADDRESS#<br />

</cfoutput>

And as Carl pointed out, make sure that there isn't more than one "getHazUserInfo" in any scope.

I just noticed that the value of your CFQUERYPARAM is #ID#.  No scope?? Like the name of the query that has ID?  And, honestly, I think that it's bad form to use things like name or ID as column or variable names - it's too easy to get things confused.  Esp. when you're elbow-deep in code.

V/r,

^_^

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