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

Similar Messages

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

  • 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 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

  • Session keeps running when the query has a syntax error

    I have a weird scenario.
    Take this query for example: select distinct physassignednum from hsi.docdeficiency where delinqlevel> 0 and dfcystatus in (1,6));
    This query has a syntax error as there is an additional bracket at the end. I know that. When I run it on STJOSE database the session keeps running and never returns. Even if I stop it, it does not. I try to disconnect, it says "Connection is currently busy. Try again?" This behavior is pretty consistent on STJOSET. If I run this query on UMASS database it gives me this error (as expected)
    ORA-00933: SQL command not properly ended
    00933. 00000 - "SQL command not properly ended"
    *Cause:   
    *Action:
    Error at Line: 1 Column: 99
    I do not know what is wrong with the STJOSE database connection that causes the session to hang and never return.
    Please help.
    -Nags
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production (both databases)
    SQL Developer Version 3.0.04 Build Main-04.34

    This does not happen in sql*plus. It does not hang. It returns a proper error message.
    HSI@stjose> select distinct physassignednum from hsi.docdeficiency where delinqlevel> 0 and dfcystatus in (1,6));
    select distinct physassignednum from hsi.docdeficiency where delinqlevel> 0 and dfcystatus in (1,6))
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    HSI@stjose>

  • Query code cotains Syntax Errors

    Hello Experts,
    In the process of upgrading from 4.6 to 6.0 ECC SAP version, we had some issues at the moment of testing Queries from SQ01 transaction, nevertheless almost all the problems with queries were solved by regenerating them all over again from SQ01 for Queries and SQ02 for Infosets.
    Everything was OK so far, until I tested this Query related to PCH Logical Database and realized that It had Syntax Errors and can't run, and the other 5 Queries related to the same Logical Database are having the same Syntax Errors and they can not be fixed by executing the Query from SQ01 or regenerating the Infoset (PCHORG) from SQ02.
    I guess the Syntax Errors must be fixed by regenerating the code in the new version, but how can I do this?
    Or, is there another process I am skipping to achieve this?
    Any ideas on this?
    Thanks in advance!

    Hello VitorDFPinheiro thanks for your answer,
    I tried to modify the errors manually but in first Instance this is not possible whitout an Access Key and secondly I think this is not the best practice due the code for queries is generated Automaticaly.
    Nevertheless I tried to correct this syntax errors by copying the code and pasted it into a new Z program and compile it, the compiler threw even more errors when I corrected the first one, so I think that this is not the way to procced.
    I guess that there should be a way to "regenerate" the query and this "regeneration" must reorganize the code and its syntax.
    Any other suggestions?
    Edited by: memo_cv on Oct 11, 2010 6:56 PM

  • Second call of an SQL query throws a syntax error?

    Private Sub RefreshDataSet()
    Dim strSQL As String = DataAdapter1.SelectCommand.CommandText
    Try
    DataSet1.Clear()
    DataAdapter1.SelectCommand.CommandText() = Trim(strSQL & " WHERE BadgeID = " & strEmployeeBadge)
    DataAdapter1.Fill(DataSet1)
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub
    When I call the above procedure, the sub does work correctly and I get the expected results / records in the dataset.  But, when I call the Sub again (to refresh the dataset) it gives me an "incorrect syntax" error.
    I'm not sure why it is doing this.  Any suggestions or ideas?

    Youjun,
    It's very frustrating when you keep asking if the code is the same, or if I have tested the code.  I've said that I debugged.. I've said I have tested the code.  Your continuing to ask me this is pointless, rude, and only serves to make YOU look
    stupid.  I'm sorry if that is rude, but please stop asking me!
    To respond:
    I supposed that the original DataAdapter1.SelectCommand.CommandText is "select * from table1"
    -Yes, the base command is similar to this, except that I call each database field, not using the *.
    1) When you run it the first time, the DataAdapter1.SelectCommand.CommandText will be "select * from table1 WHERE BadgeID ='123'".
    -Yes, I append 'WHERE BadgeID = XXX' to the query, the first and
    each subsequent time.  Again, I said that the code/call/syntax DOES NOT CHANGE.  It is the
    same every time.
    2) Then you changed the strEmployeeBadge, I supposed that is '234'
    -NO!  I do NOT change the code!!  I'm sorry, but what part of 'the query is
    exactly the same' is unclear?
    3) when you run it next time, the DataAdapter1.SelectCommand.CommandText will change to "select * from table1 WHERE BadgeID ='123'
    WHERE BadgeID = '234'"
    -NO!  I have specifically tested for this
    and as stated, the SQL syntax does not change!
    So it 'syntax' fail will pop out when second call.
    -NO, your assumptions are INCORRECT.
    I suggest you recording the commandText when first change the DataAdapter1.
    I write a testing program for you.
    -Your 'testing program' is for all purposes, the same exact code as what I used.  There is no difference.  
    Now, as also stated before, I have several other instances
    where I use the same 'technique' to amend the base SQL queries of the DataAdapter.  Each of these other instances work fine, and I use them to 'refresh' my DataSet information several times throughout the running of my program.  Just for some
    reason, this time, it does not work.  I don't know why and was hoping someone else had found the same/similar issue and also found a resolution.  The DataAdapter is configured the same as the others, the code is the same as well.  I will just
    have to find a work around, or other way to do what I want I guess.
    Lastly, yes, I set strSQL in the subroutine because I want that variable to be gone at the end of the procedure.  It recalls, then sets the syntax, every time the Sub is called on purpose.  I do not want strSQL to be 'global', which by the way,
    according to Microsoft documentation I have read, is no longer possible.  Global variables are 'technically' not used/recognized anymore.  If this has changed, then I stand corrected.
    Thank you for responding, I will just find another solution I guess.

  • ABAP Query ... syntax error ...... short dump

    Hi,
    I am getting dump when executing ABAP Query..
    Error in the ABAP Application Program
    The current ABAP program "AQL4LA==========ZTST_DATA=====" had to be terminated
    because it has
    come across a statement that unfortunately cannot be executed.
    The following syntax error occurred in program "/1BCDWB/SAPLIQ000000000486 " in
    include "/1BCDWB/LIQ000000000486$04 " in
    line 5:
    "A FUNCTION already exists with the name "/1BCDWB/IQ000000000486SSCR"."
    Any help ?
    Giri

    Hello,
    Please refer to SAP note 723577 and implement the recommendations within and regenerate the query.
    Hope this helps.
    Regards,
    David

  • Simple query ... syntax error ?

    What is wrong with this simple sql statement ?
    SELECT Caseid
    FROM (SELECT DISTINCT Caseid, userid FROM Atts)
    I get this error
    Server: Msg 170, Level 15, State 1, Line 2
    Line 2: Incorrect syntax near ')'.

    In this case, it could go either way. Because the derived
    table is
    performing the select distinct anyway, the execution plans
    would be similar,
    but you'd see one extra step for selecting all rows from the
    derived table.
    Notice that the derived table has distinct caseid, userid,
    but the main
    query only selects caseid. If the extra IO required to
    transmit the
    unwanted userid column is more expensive than the extra step
    required to
    select just the caseid column out of the derived table, then
    the derived
    table is the better choice.
    In any case, the simpler query is usually the better option.
    Unless he
    actually wants a duplicate caseid for each userid, but not
    the userid
    itself, plain ol' SELECT DISTINCT makes more sense.
    "bregent" <[email protected]> wrote in
    message
    news:ejaad1$k2u$[email protected]..
    > >On the contrary, subqueries in the FROM clause are
    quite useful and can
    > >in
    > >the right situations perform much better than
    alternative queries.
    >
    > Ah, as usual you are correct. It looks like he forgot to
    add a DT alias
    > name
    > at the end of the statement which is causing the error.
    But in any case, a
    > simple select distinct would yield the same results and
    performance,
    > correct?
    >

  • 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

  • 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.

  • SQLException syntax error in query

    I am baffled and hoping that maybe you can spot an error in my query - I can't seem to find it!
    The query is:
    INSERT INTO CreditCard (userID, type, name, number, expiration, addressID) VALUES (5, 1, 'Bill', '1264', 2004-04-10, 9)
    And in code it is:
    String sql = "INSERT INTO CreditCard (userID, type, name, number," + " expiration, addressID) VALUES (" + userId + ", " + type + ", \'" + name + "\', \'" + number + "\', " + expiration + ", " + addressId + ")";
    I keep getting error for this line:
    stmt.execute(sql);
    with the following message:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
    at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3065)
    at sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
    at jauction.server.CreditCardImpl.<init>(CreditCardImpl.java:65)
    at jauction.server.CreditCardTest.main(CreditCardTest.java:14)
    Do you spot the syntax error in the query? Is there any other reason why I could be getting this error?
    Similar INSERT INTO queries have been implemented and tested in this project of mine and they are working fine. I am baffled as to where the syntax error is in this query. If you spot it - could you point it out? Thanks.

    Thanks man, you saved me hours of debugging.
    I had an Access table with a column named TimeStamp, just couldn't get the damn thing to work. But I think both our problems are JDBC/SQL related, not Access related. In other words, it wouldn't work on any other RDBMS system either.
    Someone should put it in the documentation somewhere that using SQL datatype names for column names is a no-no.

  • Syntax error while writing a select query.

    Hi all,
    I have a requirement where I have to pick a value if the text for that value is
    MYCARu2019S Lovliest Car.
    And so I wrote a query that
    SELECT     RUECK INTO XRUECK FROM AFVC WHERE ltxa1 = ' MYCARu2019S Lovliest Car'.
                    ENDSELECT.
    But it gives me a syntax error saying     
    u201CLiterals taking up more than one line not permittedu201D.
    Can some one tell me what is wrong. I need to select RUECK value from AFVC  table if
    ltxa1 value is ' MYCARu2019S Lovliest Car'.
    Kindly help what is going wrong...
    Regards,
    Jessica Sam

    Hi,
    Narendran is right use two single quotes.
    also careful wile comparing string. i think as you write ltxa1 value is ' MYCARu2019S Lovliest Car'.
    so while comparing you must not use space just before staring use the following
    SELECT  rueck INTO xrueck FROM afvc WHERE ltxa1 = 'MYCAR''S Lovliest Car'. " Not use Space before M
    ENDSELECT.
    Hope will help you.
    Kind Regards,
    Faisal

  • Select-options in SELECT query - syntax error

    Hi all,
      I get the error below when I try to use the select options in a SELECT query . Please help me.
    "The IN operator with "SO_AWART" is followed neither by an internal
    table nor by a value list."
    The code i have used(Logical database  PNP is used):
    TABLES: pernr,
            catsdb.
    INCLUDE ztime_cwtr_top.    " global Data
    INCLUDE ztime_cwtr_f01.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME.
    SELECT-OPTIONS SO_AWART FOR CATSDB-AWART.
    PARAMETERS P_THRES TYPE I.
    SELECTION-SCREEN END OF BLOCK B1.
    Get data from CATSDB table. Workdates within the date interval are considered.
      SELECT pernr workdate awart catsquantity beguz enduz status
      FROM catsdb
      INTO TABLE it_catsdb
      WHERE pernr  = pernr-pernr    AND
           workdate GE pn-begda     AND
           workdate LE pn-endda     AND
           status   IN ('20', '30') AND
           awart    IN  so_awart .
          awart    IN ('1100', '1137', '1138', '1139', '1140',
                      '1147', '1148', '1149', '1157', '2003' ).
    when I give the values directly i do not get any syntax error, but when I use select options in the where condition I get the syntax error.
    I have tried different options like using only the select-options in the where condition.
    Thanks in advance.....
    Madhu

    Solved.
    Code with syntax error:
    include z...top .
    include z...fo1.
    select-options: xxxxxxx
    Code  with no syntax error:
    select-options: xxxxxxx
    include z...top .
    include z...fo1.
    Thanks for all your help,
    Madhu

  • Can not use SUM in a simple query because of a syntax error?

    Hi
    Thank you for reading my post.
    I am trying to execute the following query:
    q = em.createQuery("SELECT SUM((NE.pipeLength - 0.6)+((NE.networkDepth-NE.initialDepth)*0.41)+ NE.standLenght)  FROM NExpansion NE  where (( NE.contract.contractor=:contractor) AND (NE.pDiameter=:diameter))");
                  q.setParameter("contractor", contractor);
    q.setParameter("diameter", diameter);
         l =  (Long) q.getSingleResult();And I get the following error:
    Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.EJBQLException
    Exception Description: Syntax error parsing the query [SELECT SUM((NE.pipeLength - 0.6)+((NE.networkDepth-NE.initialDepth)*0.41)+ NE.standLenght)  FROM NExpansion NE  where (( NE.contract.contractor=:contractor) AND (NE.pDiameter=:diameter))], line 1, column 12: unexpected token [(].
    Internal Exception: line 1:12: unexpected token: (
            at oracle.toplink.essentials.exceptions.EJBQLException.unexpectedToken(EJBQLException.java:389)
            at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.handleANTLRException(EJBQLParser.java:350)
            at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.addError(EJBQLParser.java:278)
            at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.reportError(EJBQLParser.java:378)
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.aggregateExpression(EJBQLParser.java:1416)
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectExpression(EJBQLParser.java:1158)
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectClause(EJBQLParser.java:403)
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.selectStatement(EJBQLParser.java:178)
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.document(EJBQLParser.java:135)
            at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.parse(EJBQLParser.java:166)
            at oracle.toplink.essentials.internal.parsing.ejbql.EJBQLParser.buildParseTree(EJBQLParser.java:127)
            at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:215)
            at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:189)
            at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.buildEJBQLDatabaseQuery(EJBQueryImpl.java:153)
            at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:114)
            at oracle.toplink.essentials.internal.ejb.cmp3.base.EJBQueryImpl.<init>(EJBQueryImpl.java:99)
            at oracle.toplink.essentials.internal.ejb.cmp3.EJBQueryImpl.<init>(EJBQueryImpl.java:86)
            at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.createQuery(EntityManagerImpl.java:204)
            ... 30 more
    Caused by: line 1:12: unexpected token: (
            at oracle.toplink.essentials.internal.parsing.ejbql.antlr273.EJBQLParser.aggregateExpression(EJBQLParser.java:1365)
            ... 43 morePlease let me know what am I doing wrong?
    Thanks.

    Hello,
    From the grammar in the JPA spec, SUM only takes a state_field_path_expression which is defined as
    state_field_path_expression := {identification_variable | single_valued_association_path_expression}.state_field
    Please feel free to file an enhancement to have this expanded upon.
    Best Regards,
    Chris

Maybe you are looking for