Coldfusion query of queries error

I have a long query named "Results.Itinerary" in a CFC which
I have to add this query to.
<CFLOOP QUERY = "Results.Itinerary">
<CFQUERY NAME = "GetPorts" DATASOURCE="x">
SELECT *
FROM Itinerary_Ports
WHERE (ItineraryID = #ItineraryID#)
AND (Name NOT LIKE '%At Sea%')
</CFQUERY>
<CFSET ThisPortList = ValueList(GetPorts.Name)>
<CFSET QuerySetCell(Results.Itinerary,
"PortList","#ThisPortList#", CurrentRow)>
</CFLOOP>
Now this query below gives me an error, I know I need to have
the single quotes around PortList for it to work , but coldfusion
is getting confused and throwing errors.
<cfquery name="Search.Results.ThisShip" dbtype="QUERY">
SELECT *
From Search.Results.Itinerary
Where ShipID = #ShipID#
AND NumberOfNights = #NumberOfNights#
AND PortList = '#PortList#' < - Coldfusion will sometimes
get screwed up on this line.
ORDER BY DepartureDate ASC
I need to know a different way to write this. Thanks.

Thanks to you and Dan. I think the key was getting rid of the
apostrophies that coldfusion added. I still dont know if its a
QuerySetCell that adds them or what, but having them makes
problems.
Here is what I did to fix it
In the query I used QuotedValueList and used a delimiter.
Then I stripped out the apostrophies that coldfusion added.
Then I reset the QuerySetCell with the apostrophies removed.
<CFLOOP QUERY = "Results.Itinerary">
<CFQUERY NAME = "GetPorts" DATASOURCE="Cruises">
SELECT *
FROM Itinerary_Ports
WHERE (ItineraryID = #ItineraryID#)
AND (Name NOT LIKE '%At Sea%')
</CFQUERY>
<CFSET ThisPortList =
QuotedValueList(GetPorts.Name,";")>
<CFSET QuerySetCell(Results.Itinerary,
"PortList","#ThisPortList#", CurrentRow)>
<cfset a = replace(PortList,"'","","all")>
<CFSET QuerySetCell(Results.Itinerary, "PortList","#a#",
CurrentRow)>
</CFLOOP>
The next part I did was the "PortList IN ('#PortList#'). "
SELECT *
From Search.Results.Itinerary
Where ShipID = #ShipID#
AND NumberOfNights = #NumberOfNights#
AND PortList IN ('#PortList#')
ORDER BY DepartureDate ASC

Similar Messages

  • Query Of Queries : Error When Trying To Fake Left Outer Join

    Hi there
    I am trying to replicate a left outer join, combining two query of queries using a method I located here
    However, I keep getting an error message..
    Here is the code I am using....
        <cfquery dbtype="query" name="qry">
                    SELECT *
                    FROM returnQry, returnQry2
                    WHERE returnQry.mediumImage = returnQry2.mediumImage
                    ORDER BY returnQry.name   
                </cfquery>
                <cfquery name="returnQry3" dbtype="#application.mx#">
                    SELECT *
                    FROM trackmeanings AS t
                </cfquery>      
               <cfquery dbtype="query" name="endQry">
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE qry.name = returnQry3.sNameTrack
                    UNION
                    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
                    FROM qry, returnQry3
                    WHERE #qry.name# NOT IN (#QuotedValueList(returnQry3.sNameTrack)#)
                    GROUP BY name,nameRcd,mediumImage
                </cfquery>
    When I try to use the query output in a page, i get the error message "Incorrect conditional expression,  Expected one of [like|null|between|in|comparison] condition"
    Would anyone have any ideas?
    Many thanks

    Actually , spoke a little too soon, my query now seems to be outputting duplicates when the value is found on both sides of the union, my group by clause doesnt seem to be eliminating them like it usually does.
    My SELECT code now reads
    <cfquery dbtype="query" name="endQry">
    SELECT name,nameRcd,mediumImage, COUNT(sMessage) AS comments
    FROM qry, returnQry3
    WHERE qry.name = returnQry3.sNameTrack
    GROUP BY name,nameRcd,mediumImage
    UNION
    SELECT name,nameRcd,mediumImage, 0 AS comments
    FROM qry
    WHERE qry.name NOT IN (<cfqueryparam
    value="#returnQry3.sNameTrack#"
    cfsqltype="cf_sql_varchar"
    list="yes"
    />)
    GROUP BY name,nameRcd,mediumImage
    ORDER BY name DESC
    </cfquery>
    and my ouput...is producing duplicates
    <cfoutput query="rc.qryTopTracks" group="name">
    #rc.qryTopTracks.name#
    </cfoutput>
    Would you have any idea of how to eliminate them here?  Thanks

  • Query of Queries Error

    I am using the same datasource to create a query of queries
    but one of my queries is not being recognized. The code and error
    message are as follows:

    You don't use the datasource property with a query of query
    <cfquery...>
    tag. When you do query of query you are dealing with record
    sets in
    memory. Drop the 'datasource' parameter in the third
    <cfquery...> tag.

  • Problem using DECODE() function with a Query of Queries

    I
    posted
    on my blog about an issue I was having trying to use the PL/SQL
    DECODE() function with a Coldfusion Query of Queries. This function
    works fine when you query a database for information. However, when
    you query another query, it seems that CF doesn't recognize it. I
    got errors stating that it found a left parenthesis where it
    expected a FROM key word. Here is a simplified version of what I am
    trying to do:
    quote:
    <!--- Simulated query; similar to what I was calling from
    my database --->
    <cfscript>
    qOriginal = queryNew("Name,Email,CountryCode",
    "VarChar,VarChar,VarChar");
    newRow = queryAddRow(qOriginal, 5);
    querySetCell(qOriginal, "Name", "Joe", 1);
    querySetCell(qOriginal, "Email", "[email protected]", 1);
    querySetCell(qOriginal, "CountryCode", "AMER", 1);
    querySetCell(qOriginal, "Name", "Sally", 2);
    querySetCell(qOriginal, "Email", "[email protected]", 2);
    querySetCell(qOriginal, "CountryCode", "AMER", 2);
    querySetCell(qOriginal, "Name", "Bob", 3);
    querySetCell(qOriginal, "Email", "[email protected]", 3);
    querySetCell(qOriginal, "CountryCode", "ASIA", 3);
    querySetCell(qOriginal, "Name", "Mary", 4);
    querySetCell(qOriginal, "Email", "[email protected]", 4);
    querySetCell(qOriginal, "CountryCode", "EURO", 4);
    querySetCell(qOriginal, "Name", "John", 5);
    querySetCell(qOriginal, "Email", "[email protected]", 5);
    querySetCell(qOriginal, "CountryCode", "EURO", 5);
    </cfscript>
    <cfquery name="qCountries" dbtype="query">
    SELECT DISTINCT(CountryCode) AS CountryCode,
    DECODE(states, "AMER", "North America &amp; Canada",
    "EURO", "Europe &amp; Africa", "ASIA", "Japan &amp;
    Asia","") CountryName
    FROM qOriginal
    ORDER BY CountryCode
    </cfquery>
    <cfdump var="#qCountries#">
    <!--- ========== END OF CODE ========== --->
    So running this returned the following error:
    Query Of Queries syntax error.
    Encountered "(. Incorrect Select Statement, Expecting a
    'FROM', but encountered '(' instead, A select statement should have
    a 'FROM' construct.
    Does anybody know why this doesn't work? Is it just not
    supported? Please note that I have also tried to use the CASE()
    function instead of DECODE() and that resulted in basically the
    same error. For now I an looping over my distinct query with a
    switch statement and manually loading a new query with the data how
    I want it. But it would be a lot cleaner and less code to have the
    DECODE() to work. Thx!

    DECODE() is an Oracle function, not generic SQL. Q-of-Q is a
    very limited subset of SQL and lacks many functions and clauses
    available in standard SQL, especially what you may be used to using
    in your particular RDBMS.
    See
    Query
    of Queries user guide
    Phil

  • Coldfusion 7 query of queries

    I am getting this error when trying to run a query of queries
    on a query constructed with QueryNew(): The value "" cannot be
    converted to a number
    My hosting company recently upgraded to Coldfusion 7 and this
    is when the error began. It worked fine before this and I have not
    been able to figure out what to do to correct the issue.
    I have dumped the query that I am constructing with QueryNew
    and beside some values being null the query looks fine. I don't
    think having some null fields should pose a problem.
    Any ideas?

    Try inserting the word null instead of an empty
    string.

  • Can't find answer to Query Of Queries runtime error

    Not only I browsed this forum but also googled this problem but unfortunnately I have no luck in finding the answer.
    All I did was writing this simple query:
    <cfquery name="test" dbtype="query">
    select SSN,BirthDate from myquery where SSN <> '' OR BirthDate <> ''
    </cfquery>
    and I got this error:
    Query Of Queries runtime error.
    Comparison exception while executing <>.
    Unsupported Type Comparison Exception: The <> operator does not support comparison between the following types:
    Left hand side expression type = "DOUBLE".
    Right hand side expression type = "STRING".
    I tried the following and did not work either, still got the same error.
    <cfquery name="test" dbtype="query"> 
    select SSN,BirthDate from myquery
    where SSN <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/>  
    OR BirthDate <> <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value=""/></cfquery>
    Has someone ever encountered the same problem and know how to solve it?

    HELP ! ! !  Going into testing soon. I need this to work to get correct report results ! ! ! !
    My issue seems similar to the one under discussion and the reply from lawhite01 caught my eye. Can you roll my issue into this discussion?
    This is a 2 parter. The second part is the QoQ part, but the 1st part has a line in the query that is similar to the QoQ one and it uses the same data. Part 1 also throws an error.
    PART # 1.
    I'm trying to use a query table created through QueryNew and then query it.
    I need multiple columns in the query table I create:
    <cfscript>
            tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
        </cfscript>
    Then I populate all the cells of the query table.
    Then I set up to use the created query table.
    I do this first:
        <cfquery name="qAltPostID" datasource="#at_datasource#">
             SELECT AltPoster, fk_Job_AnnounceNum
             from JOB_JPContacts
             Where AltJPContactType = 'AltPosterID'
             and AltPoster = '#session.IHSUID#'
             </cfquery>
    Then, in my first query using the created query, I expect to need to choose from multiple values, so I'm using this line in the query (this is NOT a QoQ query):
                and AnnounceNum IN (<cfqueryparam cfsqltype="CF_SQL_varchar" value="#ValueList(qAltPostID.fk_Job_AnnounceNum)#">)
    I've also tried:
                   and AnnounceNum IN (#ValueList(qAltPostID.fk_Job_AnnounceNum)#)   
    and:
                   and JOB_AnnounceNum IN
                    SELECT fk_Job_AnnounceNum
                    from JOB_JPContacts
                    Where AltJPContactType = 'AltPosterID'
                    and AltPoster = '#session.IHSUID#'
    ERROR is: one record should return. I get 0.
    PART # 2: Here's the QoQ part.
    I get the error:
    Query Of Queries runtime error.
    Comparison exception while executing IN.
    Unsupported Type Comparison Exception: The IN operator does not support comparison between the following types:
    Left hand side expression type = "LONG".
    Right hand side expression type = "STRING".
    A tutorial I found gave an example using only one column for this part of the fix:
         tot_AllCurrentDraftListing = QueryNew("AnnounceNum", "CF_SQL_VARCHAR")
    How would I set up the query with the datatype when I'm using multiple columns:
    <cfscript>
            tot_AllCurrentDraftListing = QueryNew("AnnounceNum, JP_PDLoc, JP_JS_Title, JP_JS, JP_KW_1, JP_JobTitle, JP_Open, JP_Close, JP_CloseType, JP_CloseName, JP_PosNeed, JP_DirectHire, JP_Desc, JP_Draft, JP_Archived, JP_State, JP_AreaName, JP_AreaID, JP_AreaAlias, JP_Fac_SU, JP_Fac_Facility, JP_FAC_ID, JP_Grade1, JP_sal_low1, JP_sal_high1, JP_Grade2, JP_sal_low2, JP_sal_high2, JP_Grade3, JP_sal_low3, JP_sal_high3, JP_Grade4, JP_sal_low4, JP_sal_high4, JP_Grade5, JP_sal_low5, JP_sal_high5, JP_Posted, JP_TypeHire, JP_HRemail");
        </cfscript>
    I used this code after all the cells contained values and before running my QoQ query:
            <cfloop index="intID" from="1" to="#tot_AllCurrentDraftListing.recordcount#" step="1">
                <cfset tot_AllCurrentDraftListing["AnnounceNum"] [intID] = JavaCast("string", intID) />
            </cfloop>
              Is that correct?
    Thanks.
    Whoever can help me with this should be awarded extra points ! ! ! !

  • Query Of Queries syntax error.

    Hi all,
    I have the following query:
    <cfquery name="agent" datasource="datasourcename">
    SELECT * FROM quotes where status = 'Pending'
    <cfif isDefined("form.agent")>
    AND agent = '#FORM.agent#'
    </cfif>
    </cfquery>
    Then, I have the following query of that query
    <cfquery name="totalvalue" dbtype="query">
    SELECT SUM(value) as total FROM agent
    </cfquery>
    however I get the following error:
    Query Of Queries syntax error.
    Encountered "SUM ( value. Incorrect Select List,
    on line 20 which is:
    <cfquery name="totalvalue" dbtype="query">
    now i'm sure this is identical to what ive used before but
    getting the error. the totals query works fine when querying the
    database direct, only got this error when I changed it to query the
    master query.
    i appreciate any help in advance, as no matter how much i
    stare at it I can't see whats wrong!

    I believe that
    value is a reserved word that is probably causing your
    current error. I would rename this column, or alias it in your
    original query. Also, I would add WHERE value IS NOT NULL to your
    Q-of-Q to cover your NULLs.
    Phil

  • Query of Queries Runtime error

    I have a query pulled from an XML file, with a column that
    contains mixed numeric and alphanumeric strings, like 103, 112,
    A12,
    etc.
    When running a QofQ on this query, I get this error:
    Query Of Queries runtime error.
    Can't convert the string A1 to java type LONG
    Apparently, according to a livedocs comment I found here
    http://tinyurl.com/y24qda
    =====
    if the column's value in the first row of the recordset is
    something that is all numeric, like: 123456 When an all-numeric
    value
    like this is encountered as the first value, CF assumes that
    ALL values in that column are numeric... thus, it errors out if it
    comes accross a record containing both numbers and letters,
    since a mix of letters and numbers will be considered a string.
    =====
    Is there any known way around this?
    Michael Evangelista
    Evangelista Design
    www.mredesign.com

    Yes, running CFmx7... didnt stop to think this might be
    different in each, but found something to that effect last night...
    also, Dan's link gave me a clue... thanks.
    Michael Evangelista
    Evangelista Design
    www.mredesign.com
    "Adam Cameron" <[email protected]> wrote in message
    news:[email protected]..
    >> Ok.. will do, thanks
    >
    > Note that the advice Dan gives is specific to CFMX7,
    whereas it seems you
    > have been looking at the CFMX6 documentation... which
    version of CF are you
    > running?
    >
    > --
    > Adam

  • Using NVL in Query of Query resulting in error

    I'm still using CF8 and Oracle 11G back-end.
    When I use NVL in the query of query I got error....Can't I use NVL to check on null value? Please help
    Here is my codes:
    <cfquery name="GetC2" datasource="#Trim(application.OracDSN)#">
         SELECT CamID2, rel2_2,p_ln2,p_fn2,ins,l_year
         FROM prt_temp
         WHERE Ins = 'CC'
         AND l_year =  '1481'
    AND NVL(Child_LN2,' ') <> ' '
    AND NVL(Child_FN2,' ') <> ' '
        </cfquery>
    <cfif GetC2.Recordcount NEQ 0>   
    <cfquery name="CheckRel2C2" dbtype="QUERY">
      SELECT CamID2, rel2_2
      FROM GetC2
      WHERE NVL(Rel2_2,' ') <> ' '
    AND NVL(p_ln2,' ') = ' '
    AND NVL(p_fn2,' ') = ' '
    AND Ins = 'CC'
    AND l_year =  '1481'
    </cfquery>
    </cfif>
    The error:
    Error Executing Database Query.
    Query Of Queries syntax error.
    Encountered "NVL ( Rel2_2 ,. Incorrect conditional expression, Expected one of [like|null|between|in|comparison] condition,

    NVL is an Oracle function, and is not available in ColdFusion Query of Query.  If you are trying to check for null values, then use IS NULL or IS NOT NULL.  So
    WHERE NVL(Rel2_2,' ') <> ' '
        AND NVL(p_ln2,' ') = ' '
        AND NVL(p_fn2,' ') = ' '
    becomes
    WHERE Rel2_2 IS NOT NULL
        AND p_ln2 IS NULL
        AND p_fn2 IS NULL
    -Carl V.

  • Query of Queries problem

    Over the past several weeks we've been experiencing periodic
    hangs of the ColdFusion service. We finally invested in SeeFusion
    and found the problem, but aren't sure how to fix it
    The code that hangs is a query of queries block. Basically we
    are getting a result set from verity (~1000 rows), then getting a
    result set from SQL server (~3000 rows), and joining the two with
    the query of query statement. Everything will run fine for a few
    hours, then that block of code will bog down. When I dumped the
    threads during the error, everything gets hung like so:
    "jrpp-255" runnable
    at
    coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:439)
    at
    coldfusion.sql.imq.rttExpr.guesstimateJavaType(rttExpr.java:371)
    at
    coldfusion.sql.imq.imqTable.guessColumnType(imqTable.java:443)
    at
    coldfusion.sql.QueryTableMetaData.InferMetaDataTypes(QueryTableMetaData.java:350)
    at coldfusion.sql.imq.TableList.validate(TableList.java:166)
    at
    coldfusion.sql.imq.rttSelectExprSpec.validate(rttSelectExprSpec.java:498)
    at
    coldfusion.sql.imq.rttSelectStmt.validate(rttSelectStmt.java:84)
    at
    coldfusion.sql.imq.jdbcStatement.fetchResult(jdbcStatement.java:538)
    at
    coldfusion.sql.imq.jdbcStatement.execute(jdbcStatement.java:131)
    at coldfusion.sql.Executive.executeQuery(Executive.java:775)
    at coldfusion.sql.SqlImpl.execute(SqlImpl.java:240)
    at
    coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:500)
    at
    cfauctionManagement2ecfc978963305$funcJOINAUCTIONSTOVERITY.runFunction(D:\inetpub\wwwroot \CustomTags\mysite\component\auctionManagement.cfc:137)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:344)
    at
    coldfusion.filter.SilentFilter.invoke(SilentFilter.java:47)
    at
    coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:290)
    at
    coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:254)
    at
    coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:56)
    at
    coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:207)
    at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:366)
    at
    coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:198)
    at
    coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:157)
    at coldfusion.runtime.CfJspPage._invoke(CfJspPage.java:1594)
    at
    coldfusion.tagext.lang.InvokeTag.doEndTag(InvokeTag.java:341)
    at
    cfact_search_auctions2ecfm1040202400._factor47(D:\inetpub\wwwroot\CustomTags\mysite\actio n\act_search_auctions.cfm:849)
    at
    cfact_search_auctions2ecfm1040202400.runPage(D:\inetpub\wwwroot\CustomTags\mysite\action\ act_search_auctions.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.filter.CFVariablesScopeFilter.invoke(CFVariablesScopeFilter.java:63)
    at
    coldfusion.tagext.lang.ModuleTag.doStartTag(ModuleTag.java:255)
    at
    coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:1925)
    at
    cfindex2ecfm1952396859.runPage(D:\inetpub\wwwroot\mysite\cfml\auctions\index.cfm:18)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
    at
    coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1915)
    at
    cflas2dvegas2dtimeshares2ecfm1477369516.runPage(D:\inetpub\wwwroot\mysite\cfml\las-vegas- timeshares.cfm:1)
    at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:152)
    at
    coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:349)
    at
    coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:65)
    ...etc
    I believe this means CF is trying to "guesstimate" the java
    type of each column in the result set. We tried to work around that
    by CASTing each column as a varchar, but we still have the same
    issue.
    If anyone has an idea what the problem could be, we'd really
    appreciate any help. Also, if anyone can suggest a way to merge the
    two result sets without using SQL, that would be great too. I've
    already tried nested loops to manually build the final result set,
    but that was taking up to 5 seconds to run.
    Environment:
    CFMX 7.0.2
    Win2K
    SQL Server 2K

    > We need more information than that to display a record,
    so we select
    > everything out of the database (which is fairly quick),
    then JOIN that to the
    > verity results (WHERE auctionID = KEY).
    Right. And what do you need THOUSANDS of matches for, in one
    hit, here?
    And what do you need ALL those columns for, when dealing with
    all these
    thousands of rows. You've not really answered my question as
    to "what's
    the end result here?" What are you trying to achieve? I don't
    mean what
    you're doing to aggregate the data, but simply *why*? What is
    the
    requirement you have here to be engaging in this enterprise
    in the first
    place? Search screen? Stock control report? What?
    Is there any way of optimising how much processing you're
    doing?
    If - say - you're doing a search results screen, you probably
    don't need
    1000s of results: you probably need 20. So just ask the DB
    for 20: WHERE
    id IN (#list of 20 IDs from Verity search results#)
    If the user goes "NEXT >>", then grab the next 20
    (cache the Verity query
    somehow, rather than re-query it).
    Obviously there's some heavy-lifting processing that might
    need to process
    the whole lot. Can this not be done in a sliding window of
    results? Or
    could you not pass the list of IDs from the Verity resultset
    into the DB
    somehow, and do the filtering on the DB engine, rather than
    with CF (which
    is not very good at bulk data processing, as you're seeing.
    It's not what
    it's designed for).
    I find QoQ to be very flaky for all ut the most basic
    operations. For
    basic stuff it's fine. It does not surprise me that it seems
    to leak
    memory (or whatever it's doing) and eventually give up the
    ghost. This
    does not help you, I realise, but as a suggested practice:
    don't expect too
    much out of QoQ. Try some other method instead.
    Adam

  • SQL 2012 SP1 - How to determine a query that causes Error 8623 in SQL Log: The query processor ran out of internal resources and could not produce a query plan. This is a rare event...

    We are getting multiple 8623 Errors in SQL Log while running Vendor's software.
    How can you catch which Query causes the error?
    I tried to catch it using SQL Profiler Trace but it doesn't show which Query/Sp is the one causing an error. 
    I also tried to use Extended Event session to catch it, but it doesn't create any output either.
    Error:
    The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that
    reference a very large number of tables or partitions. Please simplify the query. If you believe you have received this message in error, contact Customer Support Services for more information.
    Extended Event Session that I used;
    CREATE EVENT SESSION
        overly_complex_queries
    ON SERVER
    ADD EVENT sqlserver.error_reported
        ACTION (sqlserver.sql_text, sqlserver.tsql_stack, sqlserver.database_id, sqlserver.username)
        WHERE ([severity] = 16
    AND [error_number] = 8623)
    ADD TARGET package0.asynchronous_file_target
    (SET filename = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xel' ,
        metadatafile = 'E:\SQLServer2012\MSSQL11.MSSQLSERVER\MSSQL\Log\XE\overly_complex_queries.xem',
        max_file_size = 10,
        max_rollover_files = 5)
    WITH (MAX_DISPATCH_LATENCY = 5SECONDS)
    GO
    -- Start the session
    ALTER EVENT SESSION overly_complex_queries
        ON SERVER STATE = START
    GO
    It creates only .xel file, but not .xem
    Any help/advice is greatly appreciated

    Hi VK_DBA,
    According to your error message, about which query statement may fail with error message 8623, as other post, you can use trace flag 4102 & 4118 for overcoming this error. Another way is looking for queries with very long IN lists, a large number of
    UNIONs, or a large number of nested sub-queries. These are the most common causes of this particular error message.
    The error 8623 occurs when attempting to select records through a query with a large number of entries in the "IN" clause (> 10,000). For avoiding this error, I suggest that you could apply the latest Cumulative Updates media for SQL Server 2012 Service
    Pack 1, then simplify the query. You may try divide and conquer approach to get part of the query working (as temp table) and then add extra joins / conditions. Or You could try to run the query using the hint option (force order), option (hash join), option
    (merge join) with a plan guide.
    For more information about error 8623, you can review the following article.
    http://blogs.technet.com/b/mdegre/archive/2012/03/13/8623-the-query-processor-ran-out-of-internal-resources-and-could-not-produce-a-query-plan.aspx
    Regards,
    Sofiya Li
    Sofiya Li
    TechNet Community Support

  • Problem with return a ColdFusion query object from a Java class

    Hi!
    I need to return a ColdFusion query object from a Java class
    using a JDBC result set ( java.sql.ResultSet);
    I have tried to pass my JDBC result set in to the constructor
    of the coldfusion.sql.QueryTable class with this code:
    ColdFusion code
    <cfset pra = createObject("java","QueryUtil").init()>
    <cfset newQuery = CreateObject("java",
    "coldfusion.sql.QueryTable")>
    <cfset newQuery.init( pra.getColdFusionQuery () ) >
    My java class execute a query to db and return QueryTable
    Java code (QueryUtil.java)
    import coldfusion.sql.QueryTable; // (CFusion.jar for class
    QueryTable)
    import com.allaire.cfx //(cfx.jar for class Query used from
    QueryTable)
    public class QueryUtil
    public static coldfusion.sql.QueryTable
    getColdFusionQuery(java.sql.ResultSet rs)
    return new coldfusion.sql.QueryTable(rs);
    but when i run cfm page and coldfusion server tries to
    execute : "<cfset pra =
    createObject("java","QueryUtil").init()>" this error appears:
    Object Instantiation Exception.
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    If i try to execute QueryUtil.java with Eclipse all it works.
    Also I have tried to return java.sql.ResultSet directly to
    coldfusion.sql.QueryTable.init () with failure.
    Do you know some other solution?

    ok
    i print all my code
    pratica.java execute a query to db and return a querytable
    java class
    import java.util.*;
    import java.sql.*;
    import coldfusion.sql.*;
    public class Pratica {
    private HashMap my;
    private String URI,LOGIN,PWD,DRIVER;
    private Connection conn=null;
    //funzione init
    //riceve due strutture converite in hashmap
    // globals
    // dbprop
    public Pratica(HashMap globals,HashMap dbprop) {
    my = new HashMap();
    my.put("GLOBALS",globals);
    my.put("DBPROP",dbprop);
    URI = "jdbc:sqlserver://it-bra-s0016;databaseName=nmobl";
    LOGIN = "usr_dev";
    PWD = "developer";
    DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    try{
    // Carico il driver JDBC per la connessione con il database
    MySQL
    Class.forName(DRIVER);
    /* Connessione alla base di dati */
    conn=DriverManager.getConnection(URI,LOGIN,PWD);
    if(conn!=null) System.out.println("Connection Successful!");
    } catch (ClassNotFoundException e) {
    // Could not find the database driver
    System.out.print("\ndriver non trovato "+e.getMessage());
    System.out.flush();
    catch (SQLException e) {
    // Could not connect to the database
    System.out.print("\nConnessione fallita "+e.getMessage());
    System.out.flush();
    //funzione search
    //riceve un hash map con i filtri di ricerca
    public QueryTable search(/*HashMap arg*/) {
    ResultSet rs=null;
    Statement stmt=null;
    QueryTable ret=null;
    String query="SELECT * FROM TAN100pratiche";
    try{
    stmt = conn.createStatement();// Creo lo Statement per
    l'esecuzione della query
    rs=stmt.executeQuery(query);
    // while (rs.next()) {
    // System.out.println(rs.getString("descrizione"));
    catch (Exception e) {
    e.printStackTrace();
    try {
    ret = Pratica.RsToQueryTable(rs);
    } catch (SQLException e) {
    e.printStackTrace();
    this.close();
    return(ret);
    // ret=this.RsToQuery(rs);
    // this.close(); //chiude le connessioni,recordset e
    statament
    //retstruct CF vede HashMap come struct
    //METODO DI TEST
    public HashMap retstruct(){
    return(my);
    //conversione resultset to querytable
    private static QueryTable RsToQueryTable(ResultSet rs)
    throws SQLException{
    return new QueryTable(rs);
    //chiura resultset statament e connessione
    private void close(){
    try{
    conn.close();
    conn=null;
    catch (Exception e) {
    e.printStackTrace();
    coldfusion code
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN">
    <html>
    <head>
    <title>Test JDBC CFML Using CFScript</title>
    </head>
    <body>
    <cftry>
    <cfset glb_map =
    createObject("java","java.util.HashMap")>
    <cfset dbprop_map =
    createObject("java","java.util.HashMap")>
    <cfset glb_map.init(glb)> <!---are passed from
    another page--->
    <cfset dbprop_map.init(glb["DBPROP"])>
    <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    <cfset ourQuery
    =createObject("java","coldfusion.sql.QueryTable").init(pra.search())>
    <cfcatch>
    <h2>Error - info below</h2>
    <cfdump var="#cfcatch#"><cfabort>
    </cfcatch>
    </cftry>
    <h2>Success - statement dumped below</h2>
    <cfdump var="#ourQuery#">
    </body>
    </html>
    error at line <cfset pra =
    createObject("java","Pratica").init(glb_map,dbprop_map)>
    An exception occurred when instantiating a java object. The
    cause of this exception was that: coldfusion/sql/QueryTable.
    -----------------------------------------------------------------------

  • Query of queries problem or bug

    Hello Everyone,
    I have used cfdirectory to get a list of files. As the result
    I receive query with the files.
    Then I want to search it using query of queries. I' ve found
    a problem and I wonder if it is a bug of Coldfusion or perhaps
    wrong usage of QoQ. The thing is that the files that I have are
    using '_' and then are followed by number of week. It seems that
    searching something like this '%_6' returns results *_*6. See
    attached code.
    Thanks for all answers in advance.

    > I think you'll find "_" is a single-char wildcard when
    used with the LIKE
    > operator.
    Found out how to escape it:
    WHERE Name LIKE '%[_]6%'
    I'm glad you brought this up... I didn't know about this
    until I looked @
    your issue. That's my new thing learned for the day: I can go
    to the pub
    now ;-)
    Adam

  • Query of queries disallows SQL right() function

    We're attempting to do a query of queries using the SQL
    right() function like this:
    select *
    from getresults
    where right([key],charindex('\',reverse([key]),1)-1) not in
    (#quotedvaluelist(getexcluded.file_name)#)
    We've even replaced that where clause with a much more simple
    where right([key])='m'
    just to make sure that it wasn't the nesting functions that
    were causing the problem.
    In either case, we get the error:
    Query of Queries syntax error.
    Encountered "right" at line 0, column 0. Incorrect
    conditional expression,
    Expected one of [like|null|between|in|comparison] condition,
    What SQL functions are disallowed from query of queries?
    Thanks,
    Kris

    Nasty stuff huh. Just happened to discover myself today that
    Left doesn't work. I'd suspect that Aggregate functions are the
    ONLY ones that will work. It would have been nice if they'd at
    least allowed CF vs DB functions in their own "database" language.
    BTW, also discovered that Count() returns Null rather than 0
    when there aren't any per your WHERE clause.

  • Bug in CF11 regarding Query of queries syntax?

    So I have decided to try CF11 because of an official outstanding CF10 bug.
    Once I installed CF11, I get an error when running code like this:
    <cfquery name="LOCAL.stat_questions" datasource="#APPLICATION.dsn#">
         SELECT     survey_questionID
         FROM     tbl_survey_questions
    </cfquery>
    <cfset LOCAL.this_statID = 1>
    <cfquery name="LOCAL.subset" dbtype="query">
         SELECT     survey_questionID
         FROM          [LOCAL].stat_questions
         WHERE     survey_questionID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#LOCAL.this_statID#">
    </cfquery>
    The error I receive is: "Query Of Queries syntax error.
      Encountered ";. "
    If I remove the semi-colon... No error! Is this a bug, or was the semi-colon always bad, but just ignored?
    Thanks

    I just always put it in out of habit from typing out actual MySQL queries (non QoQ). Never was a problem and I always did it. Now running CF11... it requires fixing. Thought it was strange.
    I actually didn't even notice that the semi-colons weren't required in QoQ until I ran into this CF11 bug. I also notice the semi-colon isn't necessary for a MySQL query either in cfquery! Seems weird that it accepts them, but isn't required. Just ignores them?

Maybe you are looking for