20 Replies Latest reply on May 9, 2016 7:19 AM by rpschwar27

    Coldfusion 2016

    rpschwar27 Level 1

      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.

        • 1. Re: Coldfusion 2016
          Carl Von Stetten Adobe Community Professional & MVP

          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.

          • 2. Re: Coldfusion 2016
            rpschwar27 Level 1

            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

            • 3. Re: Coldfusion 2016
              Carl Von Stetten Adobe Community Professional & MVP

              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"?

              • 4. Re: Coldfusion 2016
                WolfShade Level 4

                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,

                 

                ^_^

                • 5. Re: Coldfusion 2016
                  rpschwar27 Level 1

                  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>

                  • 6. Re: Coldfusion 2016
                    WolfShade Level 4

                    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,

                     

                    ^_^

                    • 7. Re: Coldfusion 2016
                      rpschwar27 Level 1

                      the cfdumps are just to see if the query worked they are not used in the final code.

                      • 8. Re: Coldfusion 2016
                        WolfShade Level 4

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

                         

                        V/r,

                         

                        ^_^

                        • 9. Re: Coldfusion 2016
                          rpschwar27 Level 1

                          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.

                          • 10. Re: Coldfusion 2016
                            WolfShade Level 4

                            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,

                             

                            ^_^

                            • 11. Re: Coldfusion 2016
                              rpschwar27 Level 1

                              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?

                              • 12. Re: Coldfusion 2016
                                WolfShade Level 4

                                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,

                                 

                                ^_^

                                • 13. Re: Coldfusion 2016
                                  rpschwar27 Level 1

                                  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?

                                  • 14. Re: Coldfusion 2016
                                    WolfShade Level 4

                                    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,

                                     

                                    ^_^

                                    • 15. Re: Coldfusion 2016
                                      WolfShade Level 4

                                      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,

                                       

                                      ^_^

                                      • 16. Re: Coldfusion 2016
                                        rpschwar27 Level 1

                                        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.

                                        • 17. Re: Coldfusion 2016
                                          haxtbh Level 4

                                          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.

                                          • 18. Re: Coldfusion 2016
                                            rpschwar27 Level 1

                                            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.

                                            • 19. Re: Coldfusion 2016
                                              WolfShade Level 4

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

                                               

                                              V/r,

                                               

                                              ^_^

                                              • 20. Re: Coldfusion 2016
                                                rpschwar27 Level 1

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