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

Similar Messages

  • JDQL named query syntax error

    Hi,
    we have a syntax error in our JDOQL-namedQuery. We want to do a join over
    two tables "TestOrder" and "TestOrderPosition" and get this error:
    (we use Kodo 4.0)
    <?xml version="1.0"?>
    <jdoquery>
    <package name="salt.domain.orderservice.entity">
    <class name = "TestOrder">
         <query name="findByOrderId">select where
    testOrderPositions.contains(testOrderPosition) and
    testOrderPosition.description==:t variables
    salt.domain.orderservice.entity.TestOrderPosition testOrderPosition</query>
    </class>
    </package>
    </jdoquery>
    <4|false|4.0.0EA3> kodo.jdo.UserException: An error occurred while parsing the
    query filter "testOrderPositions.contains(testOrderPosition) and
    testOrderPosition.description==:t". Error message: The JDOQL string is not
    valid. Make sure all parentheses are matched and that you use proper Java
    syntax.
         kodo.query.AbstractExpressionBuilder.parseException(AbstractExpressionBuilder.java:92)
         kodo.query.jdoql.JDOQLExpressionBuilder.evalExpression(JDOQLExpressionBuilder.java:508)
         kodo.query.jdoql.JDOQLExpressionBuilder.eval(JDOQLExpressionBuilder.java:265)
         kodo.query.jdoql.JDOQLParser.eval(JDOQLParser.java:98)
         kodo.query.ExpressionStoreQuery$DataStoreExecutor.<init>(ExpressionStoreQuery.java:542)
         kodo.query.ExpressionStoreQuery.newDataStoreExecutor(ExpressionStoreQuery.java:154)
         kodo.query.QueryImpl.createExecutor(QueryImpl.java:807)
         kodo.query.QueryImpl.compileForDataStore(QueryImpl.java:741)
         kodo.query.QueryImpl.compileForExecutor(QueryImpl.java:721)
         kodo.query.QueryImpl.compile(QueryImpl.java:635)
         kodo.kernel.BrokerImpl.namedQuery(BrokerImpl.java:3681)
         kodo.kernel.DelegatingBroker.namedQuery(DelegatingBroker.java:1587)
         kodo.jdo.PersistenceManagerImpl.newNamedQuery(PersistenceManagerImpl.java:1028)
         salt.domain.orderservice.dao.jdo.JDOOrderRepositoryImpl.findOrderWithPositionById(JDOOrderRepositoryImpl.java:85)
         salt.domain.orderservice.OrderRepositoryImpl.findOrderWithPositions(OrderRepositoryImpl.java:91)
         salt.domain.orderservice.OrderServiceImpl.getOrderWithPosition(OrderServiceImpl.java:15)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         java.lang.reflect.Method.invoke(Unknown Source)
         org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
         org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
         org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
         org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
         $Proxy0.getOrderWithPosition(Unknown Source)
         salt.application.DddTestController.handleRequest(DddTestController.java:40)
         org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
         org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:717)
         org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)
         org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
         org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Does anyone have an idea?
    Thanks,
    Ingo Schneider

    Thanks for your help! It works now!
    I have another problem with a very simple query:
    I always get a ClassCastException with the follwoing query. If I left the
    result parameter out the query works. Parameter "t" is an integer, but
    there shouldn't be any cast problems between integer and long.
    <?xml version="1.0"?>
    <jdoquery>
         <package name="salt.domain.orderservice.entity">
              <class name="TestOrder">
         <query name="findByOrderIdPosition">select idOrder where
    idOrder==:t</query>
    </class>
    </package>
    </jdoquery>
    public class TestOrder implements Serializable{
         private String description;
         private long idOrder;
         private Set testOrderPositions = new HashSet();
    getters & setters...
    java.lang.ClassCastException: java.lang.Long
         salt.domain.orderservice.dao.jdo.JDOOrderRepositoryImpl.findOrderWithPositionById(JDOOrderRepositoryImpl.java:99)
         salt.domain.orderservice.OrderRepositoryImpl.findOrderWithPositions(OrderRepositoryImpl.java:91)
         salt.domain.orderservice.OrderServiceImpl.getOrderWithPosition(OrderServiceImpl.java:15)
         sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         java.lang.reflect.Method.invoke(Unknown Source)
         org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:335)
         org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
         org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
         org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
         org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
         $Proxy0.getOrderWithPosition(Unknown Source)
         salt.application.DddTestController.handleRequest(DddTestController.java:40)
         org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44)
         org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:717)
         org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:658)
         org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:392)
         org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:347)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    Thanks,
    Ingo Schneider

  • MDX Query Syntax error

    I have a simple MDX query is shown in below:
    SELECT [Accounts].[pv] ON ROWS,
    [Reporting].Members ON COLUMNS
    FROM RoggeBSO.Db
    (please note that Accounts, pv and Reporting words are in square brackets)
    When I execute this query on the MDX Script Editor (in EAS), I get the following syntax error:
    Statement Executed with warnings.
    Syntax error in input MDX Query on line 1 at token 'ON'
    Unexpected Essbase error 1260052
    I tried this on both ASO & BSO cubes but didn't work. Could anyone help please?
    Regards
    Chandra
    Edited by: user2695091 on 22-Apr-2009 03:27

    SELECT {[Accounts].[pv]} ON ROWS,
    {[Reporting].Members} ON COLUMNS
    FROM RoggeBSO.Db

  • 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

  • InfoSet Query: Syntax Error while generating the program.

    Dear All,
    I have a Query in CRM system which contains an Infoset based on LDB.
    The InfoSet Query throws up a Syntax error while generating the program.
    So, we are not able to change the Infoset using the Infoset Query through SQ01.
    The error is as follows:-
    Syntax error in program "AQZZ==/SAPQUERY/CRM_ACTMON1 ".
    Error in the ABAP Application Program
    The current ABAP program "CL_QUERY_OUTPUT_DEFINITION====CP" had to be
    terminated because it has
    come across a statement that unfortunately cannot be executed.
    The following syntax error occurred in program "AQZZ==/SAPQUERY/CRM_ACTMON1 "
    in include "AQZZ==/SAPQUERY/CRM_ACTMON1 " in
    line 28:
    ""CRMT_REPORT_LOCATORLIST" must be a flat structure. You cannot use int"
    "ernal tables, strings, references, or structures as components. -"
    Please help me arrive at an solution, so that we are able to change the Infoset through the InfoSet Query.
    Awaiting your reply as soon as possible.
    Thanks and Regards,
    Pankaj.

    There is an error in your query, specifically in the definition of CRMT_REPORT_LOCATORLIST. In the short dump (transaction ST22) you will see more details and the exact location of an error if you just scroll down.
    I can't tell more because this problem is specific to your system, to which I have no access. Read the whole dump and look at all the objects mentioned there.

  • Query syntax error after multiprovider change

    Hi everyone,
    I removed key figures from a multicube, changed a query on top afterwards and saved it. The key figures are no longer in the key figure list of the query in the Query designer, and are no longer used in any place within the query.
    Now, I'm getting a syntax error on query execution, since the compiled query still contains a reference to the old key figures. Regeneration via RSRT or saving under a new name doesn't work, and to delete the generated report I need a developer key.
    Any ideas?
    Regards,
    Tilman

    Hi Shashank,
    thanks for your response.
    I did try the "check query" button, it didn't return an error. When executing the query via rsrt, I get a dump due to "Syntax error in program GP48VM7K0MSF08DRO2382A2PSTI ". The program still contains data type references to the removed infoobjects. When checking the program via SE38, you get just that syntax error.
    I'm looking for a way to clean these things up. Even when creating a new query on the aggregation level (I was talking about a multiprovider earlier, which is located underneath), the error pops up. I activated all the objects along the way, with no effect.
    Regards,
    Tilman

  • Query syntax error

    Hi,
    I've a query for a report as below. I want distinct donor code whereas i have 2 or more customers with same name and i want to retrieve data of customers between specific donor codes.I've a syntax error where i give 'between' for the following syntax in the code
    DONOR_TAB.DONOR_CODE BETWEEN DONOR_TAB.DONOR_CODE=:p_code AND DONOR_TAB.DONOR_CODE=:p_code
    The following is the query:
    SELECT ALL INITCAP(TITLE_TAB.TITLE_NAME||' '||DONOR_TAB.FIRST_NAME||' '||DONOR_TAB.MIDDLE_NAME||' '||DONOR_TAB.LAST_NAME) donor_name,
    RTRIM(INITCAP(RPAD(DONOR_TAB.ADDRESS1, 35, ' ')||RPAD(DONOR_TAB.ADDRESS2, 35, ' ')||RPAD(DONOR_TAB.STREET, 30, ' '))) DISPLAY_COL2,
    INITCAP(CITY_MASTER_TAB.CITY_NAME||' - '||DONOR_TAB.PIN) DISPLAY_COL3,
    INITCAP(CITY_MASTER_TAB.STATE_NAME||', '||CITY_MASTER_TAB.COUNTRY_NAME) DISPLAY_COL4,
    UPPER('DONOR CODE'||' - '||CITY_MASTER_TAB.CITY_NAME||'/'||DONOR_TAB.DONOR_CODE) DISPLAY_COL5
    FROM DONOR_TAB, CITY_MASTER_TAB, TITLE_TAB, DONOR_PROG_TAB
    WHERE donor_tab.donor_code = donor_prog_tab.donor_code AND DONOR_TAB.CITY_CODE = CITY_MASTER_TAB.CITY_CODE
    AND DONOR_TAB.TITLE_CODE = TITLE_TAB.TITLE_CODE
    OR DONOR_TAB.DONOR_CODE = :p_code
    OR DONOR_TAB.DONOR_CODE BETWEEN DONOR_TAB.DONOR_CODE=:p_code AND DONOR_TAB.DONOR_CODE=:p_code
    OR DONOR_TAB.LANG = :P_LANG
    OR DONOR_TAB.REMINDER = :P_REMINDER
    ORDER BY DONOR_TAB.DONOR_CODE
    Can you help me as to how i rectify this error
    Thanks

    Syntax is like this
    DONOR_TAB.DONOR_CODE BETWEEN :p_code AND :p_code
    Note:
    You hav given initial and final values as same(p_code)

  • MySQL InnerJoin query syntax error?

    I can't seem to locate the syntax error in this MySQL query.  Coldfusion says there an error in my sql syntax.  Here is the query.  Anyone have any clues on this?
    <cfquery name="queryItem" datasource="bonus">
    select
    p.productid,
    p.modelnumber,
    p.modeldescription,
    sp.sp_bonusamount as Amount
    from
    products i join bonusproducts sp on i productid = sp.sp_productid
    inner join program p on sp.sp_programid = p.programid
    where
    p.CompanyOrgLevelID in (#getParentCompanyOrgLevelIDList(session.CompanyOrgLevelID)#)
    and p.ProgramID = #programID#
    <cfif categoryID gt 0>
    and CategoryID in (#getSubcategoryIDList(categoryID)#)
    </cfif>
    order by
    #sortColumn# #sortDirection#
    </cfquery>

    To troubleshoot, run this:
    select
    p.productid,
    p.modelnumber,
    p.modeldescription,
    sp.sp_bonusamount as Amount
    from
    products i join bonusproducts sp on i productid = sp.sp_productid
    inner join program p on sp.sp_programid = p.programid
    where 1 = 2
    If it runs successfully, keep adding bits and pieces until it crashes.  Then you'll know what made it crash.
    Also enable debugging so you can see the sql that gets generated from your code.   That's often useful.

  • SQL query syntax error .......

    I am using following query
    SELECT PERNR VORNA NACHN GBDAT FROM PA0002
        INTO CORRESPONDING FIELDS OF TABLE ITAB
        WHERE UPPER( VORNA )  = UPPER( STRU_USERIP-VORNA )
        AND   ENDDA >= SY-DATUM
        AND   BEGDA <= SY-DATUM .
    and I am geting syntax error as --
    vorna is   not valid comparison operator .
    can anyone plz suggest me solution over this problem .

    Logic must be written,
    The below logic is incomplete
    Break your head and modify it
    TABLES:pa0002.
    DATA:itab TYPE TABLE OF pa0002.
    DATA:wa TYPE pa0002.
    DATA:lv_vorna TYPE pa0002-vorna.
    DATA:ra_vorna TYPE RANGE OF pa0002-vorna.
    DATA:wa_vorna LIKE LINE OF ra_vorna .
    DATA:lv_index TYPE i.
    DATA:offset TYPE i.
    DATA:pa_vorna TYPE pa0002-vorna VALUE 'Frank'.
    DATA:len TYPE i.
    len = STRLEN( pa_vorna ).
    MOVE pa_vorna TO lv_vorna.
    TRANSLATE lv_vorna TO LOWER CASE.
    wa_vorna-low = lv_vorna.
    APPEND wa_vorna TO ra_vorna.
    MOVE pa_vorna TO lv_vorna.
    TRANSLATE lv_vorna TO UPPER CASE.
    wa_vorna-low = lv_vorna.
    APPEND wa_vorna TO ra_vorna.
    wa_vorna-low = PA_VORNA.
    APPEND wa_vorna TO ra_vorna.
    TRANSLATE PA_VORNA TO LOWER CASE.
    DO len TIMES.
      lv_index = sy-index - 1.
      offset = lv_index + 1.
      DO len TIMES.
        MOVE pa_vorna TO lv_vorna.
        TRANSLATE lv_vorna+lv_index(offset) TO UPPER CASE.
        wa_vorna-low = lv_vorna.
        APPEND wa_vorna TO ra_vorna.
        ADD 1 TO lv_index.
      ENDDO.
    ENDDO.

  • MDX query : Syntax error at token 'NONEMPTYMEMBER'

    Syntax error when executing this very simplified MDX query :
    WITH
    MEMBER [ANNEE].[YEAR1] AS
    NONEMPTYMEMBER FY10
    [FY10]
    MEMBER [ANNEE].[YEAR2] AS
    NONEMPTYMEMBER [FY10]
    [FY10]
    SELECT
    {[YEAR1],[YEAR2]} ON COLUMNS
    FROM [MICOPIGE.COM_MBU]
    Syntax error in input MDX query on line 9 at token 'NONEMPTYMEMBER'
    Note that line 9 "NONEMPTYMEMBER FY10" is a copy of line 4
    No error if I delete line 4
    Any help to understand and fix this error would be greatly appreciated.

    Precision : My goal is to reduce the 30mn duration of a complex MDX query with many calculated members, using the NONEMPTYMEMBER token.

  • Simple offset - syntax error

    I get a syntax error doing this.
    calmoyr1 = request->get_form_field( 'calmoyr' ).
    calyr = calmoyr1+0(4).
    calmo = calmoyr1+4(2) - 2.
    concatenate calyr calmo into calmoyr1.
    I tried to declare calmo and calyr as N but it still gives me error.

    try this...
    store the value of the
    calmoyr1  = request->get_form_field( name = 'varible ).
    in a different varibale and do the manupulation.
    DATA: calmoyr1 TYPE string,
           calyr TYPE string,
          calmo TYPE string.
    calmoyr1 = '1234567890123456789'.
    calyr = calmoyr1+0(4).
    calmo = calmoyr1+4(2) - 2.
    CONCATENATE calyr calmo INTO calmoyr1.
    SOrry for my previous post..
    Message was edited by:
            Amandeep Bal

  • XPATH Database Query Syntax in an Assign

    Trying to get an XPATH Database query to work by assigning the Input variable value in a simple BPEL Process to my query condition. I keep getting invalid XPATH errors. I cannot seem to figure out how get write it out.
    Here is what I have:
    <from expression="orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')"/>
    Here is my error:
    Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\ReadDB\ReadDB.bpel", xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "80" the exception is Expected: ). Please verify the xpath query "orcl:query-database( 'select ename from emp where ename = bpws:getVariableData('inputVariable','payload','/client:ReadDBProcessRequest/client:input')' ,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
    Any help?
    Thanks!!!

    Ok. I have figured out how to place the condition (variable value) inside a concatentated string. So my final result is the actual XPATH Query-Database statement. But the problem is it is being returned as a String. How can I turn that final string into the XPATH expression I need? I suspect another <COPY> block could pull this off but I am not sure how to do it.
    Here is my code:
    <process name="QueryBuild" targetNamespace="http://xmlns.oracle.com/QueryBuild" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20" xmlns:ns1="http://www.w3.org/2001/XMLSchema" xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:client="http://xmlns.oracle.com/QueryBuild" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="client:QueryBuild" myRole="QueryBuildProvider"/>
    </partnerLinks>
    <variables>
    <variable name="inputVariable" messageType="client:QueryBuildRequestMessage"/>
    <variable name="outputVariable" messageType="client:QueryBuildResponseMessage"/>
    <variable name="QueryText" type="ns1:string"/>
    </variables>
    <sequence name="main">
    <receive name="receiveInput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="inputVariable" createInstance="yes"/><!-- Generate reply to synchronous request -->
    <assign name="Assign_1">
    <copy>
    <from expression="concat(&quot;orcl:query-database('select ename from emp where empno = &quot;, bpws:getVariableData('inputVariable','payload','/client:QueryBuildProcessRequest/client:input'), &quot;,false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL)'&quot;)"/>
    <to variable="QueryText"/>
    </copy>
    <copy>
    <from variable="QueryText"/>
    <to variable="outputVariable" part="payload" query="/client:QueryBuildProcessResponse/client:result"/>
    </copy>
    </assign>
    <reply name="replyOutput" partnerLink="client" portType="client:QueryBuild" operation="process" variable="outputVariable"/>
    </sequence>
    </process>

  • 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

  • MS SQL - Syntax error for valid query

    I have a problem with the second query in this code (gives me
    a syntax error in my HAVING line)
    <cfquery name="getDupes" datasource="#application.ODBC1#"
    dbtype="ODBC" username="#application.userNameODBC1#"
    password="#application.userPassODBC1#">
    SELECT *
    FROM view_FormCount
    WHERE formCount >= 2
    ORDER BY formNum
    </cfquery>
    <cfset variables.lstForms = "">
    <cfoutput query="getDupes">
    <cfset variables.lstForms=
    listAppend(variables.lstForms,"'#getDupes.formNum#'")>
    </cfoutput>
    <cfset variables.whereClause = "(formNum =
    #ReplaceNoCase(variables.lstForms,',',' OR formNum =
    ','ALL')#)">
    <cfquery name="getDetails"
    datasource="#application.ODBC1#" dbtype="ODBC"
    username="#application.userNameODBC1#"
    password="#application.userPassODBC1#">
    SELECT tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr
    FROM tblForms INNER JOIN tblCompanies ON tblForms.formCustNum
    = tblCompanies.companyNum
    GROUP BY tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr
    HAVING #variables.whereClause#
    ORDER BY tblForms.formNum, tblForms.formCustNum
    </cfquery>
    Now, the really odd thing is if I just take the query text
    out of the CFQUERY tags and use CFOUTPUT instead (to see in my
    browser what query is getting executed) I get a query that I can
    paste into Enterprise Mgr and runs fine.
    I can even paste the resulting text into my code in a CFQUERY
    and CF will run it fine.
    In other words, the dynamic version query gives me an error,
    but if I just output the SQL statement, copy-and-paste that into
    the CFQUERY that's erroring out (replacing what's there) to run as
    a static query, it works fine (sample of static query below).
    The error I get when I try to do it dynamically is "Error
    Executing Database Query. [Macromedia][SQLServer JDBC
    Driver][SQLServer]Line 4: Incorrect syntax near '10169318'. The
    error occurred on line 21." which is where the HAVING clause
    starts.
    SELECT tblForms.formNum, tblForms.formName,
    tblForms.formCustNum, tblCompanies.companyAbbr FROM tblForms INNER
    JOIN tblCompanies ON tblForms.formCustNum = tblCompanies.companyNum
    GROUP BY tblForms.formNum, tblForms.formName, tblForms.formCustNum,
    tblCompanies.companyAbbr HAVING (formNum = '10169318' OR formNum =
    '1016CONCERTA' OR formNum = '1016NSAIDS' OR formNum =
    '1016STRATTERA' OR formNum = '1016WELLBUTRIN' OR formNum =
    '18504211' OR formNum = '185093807' OR formNum = '73208565' OR
    formNum = '732120027' OR formNum = '7322154' OR formNum = '7323402'
    OR formNum = '7323522' OR formNum = '73238900' OR formNum =
    '7324211' OR formNum = '7324211S' OR formNum = '7324265' OR formNum
    = '73242891' OR formNum = '732434341' OR formNum = '732434342' OR
    formNum = '73243435' OR formNum = '73243436' OR formNum =
    '73243439' OR formNum = '73243440' OR formNum = '73243441' OR
    formNum = '73243442' OR formNum = '73243443' OR formNum = '7324359'
    OR formNum = '7324360' OR formNum = '7324370' OR formNum =
    '7324560' OR formNum = '7324959' OR formNum = '7326411ptreg' OR
    formNum = '7326599' OR formNum = '7326600' OR formNum = '7326620'
    OR formNum = '7326707' OR formNum = '7326931' OR formNum =
    '7328410' OR formNum = '732851031TOP' OR formNum = '7328512' OR
    formNum = '7328548' OR formNum = '7328548P2' OR formNum =
    '7328548P3' OR formNum = '7328548P4' OR formNum = '73289400' OR
    formNum = '73290D' OR formNum = '7329154' OR formNum =
    '73291544JHS' OR formNum = '73291545JHS' OR formNum =
    '73291546JHSMH' OR formNum = '73291547JHSMH' OR formNum = '7329174'
    OR formNum = '7329308' OR formNum = '7329402' OR formNum =
    '7329424' OR formNum = '7329455' OR formNum = '7329520' OR formNum
    = '7329539' OR formNum = '73297701JH' OR formNum = '73298273' OR
    formNum = '73298400' OR formNum = '73298403' OR formNum =
    '73298404' OR formNum = '7329883' OR formNum = '73298860' OR
    formNum = '7329887' OR formNum = '73298974' OR formNum = '7329899'
    OR formNum = '7329899S' OR formNum = '73299190' OR formNum =
    '7329987' OR formNum = '7329999PTO' OR formNum = '732AV5160' OR
    formNum = '732CMHFRAZ' OR formNum = '732HIPAA' OR formNum =
    '732HIPAAFLYERS' OR formNum = '734HEART' OR formNum = '7444711' OR
    formNum = '7449230' OR formNum = '744HR4991' OR formNum =
    '7538014MI' OR formNum = '77511044' OR formNum = '77511045' OR
    formNum = '775stampnochange' OR formNum = '80851001BLUE' OR formNum
    = '80MR4200' OR formNum = '80MR4273' OR formNum = '80MR4274' OR
    formNum = '80MR4300' OR formNum = '80MR9934' OR formNum =
    '80MR9935' OR formNum = '80SHC100' OR formNum = '80SHC4301' OR
    formNum = '80SHC9830' OR formNum = '80SHC9832') ORDER BY
    tblForms.formNum, tblForms.formCustNum

    AWFrueh1808 wrote:
    > OK, that's simple enough. But then I'm really confused
    as to why the query in
    > my original post/example didn't work.
    >
    > The only single quotes in my #whereClause# variable were
    wrapped around each
    > varchar value in the WHERE clause (well, HAVING) as in
    HAVING formNum = '12345'
    > OR formNum = '54321'
    >
    > I never used a single quote within the value itself. And
    yet
    > preservesinglequotes fixed it. So what was CF doing? Why
    did the single
    > quotes still show up in the error msg - and in the right
    place?
    >
    As I said the default behavior is to escape the quotes in
    your variables
    as data. So the default output of your SQL statement, before
    preserveSingleQuotes() would be like this.
    HAVING formNum = ''12345'' OR formNum = ''54321''
    As you can see that is not the desired results in your case.
    In your
    case you have the proper number of single quotes in your
    string and you
    do not want any added. You want to preserve them so to say.
    Thus
    adding preserveSingleQuotes() around your whereClase
    variable, i.e.
    preserveSingleQuotes(whereClause) says do not add any quotes,
    keep them
    all single.

  • Syntax error in insert query

    I have a flash form that is used to inserts a record into an
    Access database table. In the for there are 4 datefields, several
    text input fields, and several select fields. When I submit the
    form, I get a syntax error that reads:
    Executing Database Query. [Macromedia][SequeLink JDBC
    Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver]
    Syntax error in INSERT INTO statement.
    The error occurred on line 184. Complex object types cannot
    be converted to simple values.
    Line 184 is the last line of the Values in the insert query.
    The query looks like this:
    <CFQUERY DATASOURCE="#REQUEST.DataSource#">
    INSERT INTO EstimateNumber(
    BidNumber,
    Project,
    JobSite,
    EstimatedBy,
    Region,
    Company,
    Division,
    InquiryNumber,
    SafetyChecklist,
    SafetyChecklistDate,
    QCChecklist,
    QCChecklistDate,
    EstimatedValue,
    UserUsername,
    UserPassword,
    Updated,
    ReviewDate,
    ReviewedBy,
    Discipline,
    BidDate,
    JobNumber,
    UpdatedBy
    VALUES(
    #FORM.BidNumber#,
    '#FORM.Project#',
    '#FORM.JobSite#',
    '#FORM.EstimatedBy#',
    #FORM.Region#,
    #FORM.Company#,
    #FORM.Division#,
    '#FORM.InquiryNumber#',
    #FORM.SafetyChecklist#,
    #FORM.SafetyChecklistDate#,
    #FORM.QCChecklist#,
    '#FORM.QCChecklistDate#',
    #FORM.EstimatedValue#,
    '#FORM.UserUsername#',
    '#FORM.UserPassword#',
    #FORM.Updated#,
    #FORM.ReviewDate#,
    #FORM.ReviewedBy#,
    #FORM.Discipline#,
    #FORM.BidDate#,
    #FORM.JobNumber#,
    '#FORM.UpdatedBy#'
    </CFQUERY>
    Any recomendations?

    Date/Time in Access provide some pretty strage hurdles. In
    many occassions I have simply changed the field to a Text field and
    ran with that and never seemed to have problems with the result. I
    didn't like doing it but I never received errors. I have been
    receiving some parameter errors with <cfqueryparam> like the
    database doesn't recognized the preceding declared field in the
    update or insert query. Here is an example of a wierd error with
    Access. I have 2 tables. One is for estimate numbers and the other
    is for sub estimate numbers that can be assigned to specific
    estimate numbers. If is actually a complicated explanation about
    what is taking place behind the doors on this. The concept is
    simple on the surface. Both tables have the same fields except the
    subestimate table has 1 extra for a user defined subestimate
    number. The only relation between the two will be the estimate
    number. This insert works fine.
    INSERT INTO EstimateNumber(
    BidNumber,
    Project,
    JobSite,
    EstimatedBy,
    Region,
    Company,
    Division,
    InquiryNumber,
    SafetyChecklist,
    SafetyChecklistDate,
    QCChecklist,
    QCChecklistDate,
    EstimatedValue,
    UserUsername,
    UserPassword,
    ReviewDate,
    Discipline,
    BidDate,
    JobNumber,
    UpdatedBy
    VALUES(
    #FORM.BidNumber#,
    '#FORM.Project#',
    '#FORM.JobSite#',
    '#FORM.EstimatedBy#',
    #FORM.Region#,
    #FORM.Company#,
    #FORM.Division#,
    '#FORM.InquiryNumber#',
    #FORM.SafetyChecklist#,
    <cfqueryparam
    value="#FORM.SafetyChecklistDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.QCChecklist#,
    <cfqueryparam
    value="#FORM.QCChecklistDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.EstimatedValue#,
    '#FORM.UserUsername#',
    '#FORM.UserPassword#',
    <cfqueryparam
    value="#FORM.ReviewDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.Discipline#,
    <cfqueryparam
    value="#FORM.BidDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.JobNumber#,
    '#FORM.UpdatedBy#'
    This next one is the same exact query with the same table
    setup with one added field but kicks back a parmeter error
    expecting 4. I can't explain it.
    INSERT INTO SubEstimate(SubBidNumber,
    BidNumber,
    Project,
    JobSite,
    EstimatedBy,
    Region,
    Company,
    Division,
    InquiryNumber,
    SafetyChecklist,
    SafetyChecklistDate,
    QCChecklist,
    QCChecklistDate,
    EstimatedValue,
    UserUsername,
    UserPassword,
    ReviewDate,
    Discipline,
    BidDate,
    JobNumber,
    UpdatedBy
    VALUES(#FORM.SubBidNumber#,
    #FORM.BidNumber#,
    '#FORM.Project#',
    '#FORM.JobSite#',
    '#FORM.EstimatedBy#',
    #FORM.Region#,
    #FORM.Company#,
    #FORM.Division#,
    '#FORM.InquiryNumber#',
    #FORM.SafetyChecklist#,
    <cfqueryparam
    value="#FORM.SafetyChecklistDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.QCChecklist#,
    <cfqueryparam
    value="#FORM.QCChecklistDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.EstimatedValue#,
    '#FORM.UserUsername#',
    '#FORM.UserPassword#',
    <cfqueryparam
    value="#FORM.ReviewDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.Discipline#,
    <cfqueryparam
    value="#FORM.BidDate#"
    cfsqltype="CF_SQL_DATE "
    maxlength="50"
    >,
    #FORM.JobNumber#,
    '#FORM.UpdatedBy#'
    IF I get rid of the cfqueryparam fields it works. If I simply
    remove the param, I get a Syntax error. Needless to say I commented
    this query for the sake of sanity for the time being.

Maybe you are looking for

  • I can't click on objects on a website

    When I want to click on on object on a website (such as to order something, or on a toolbar object), it will not work. This is happening in areas where I could click in the past with no problem. I am using Firefox 4 in Vista.

  • IDVD problems burning more copies if I shut down the compute

    I have always had a problem with burning iDVD projects. I can burn them fine but if I shut down my comp. & want to burn another copy later I can never do this. I think maybe I am doing something wrong when I quit iDVD. This time I can't even play the

  • Assigning Handling Unit to the Inbound Delivery

    Could anyone please give me an example of code (using FM 'ws_delivery_update' and probably others) to assign a HU created by transaction HU02 (status PLND)to the inbound delivery (like VL32N). After such assignment I want to create an appropriate Tra

  • FORM based on a SP

    Build a FORM based on a database stored procedure (SP) in Portal is very easy. Is this easy too to modify the FORM if I modify the amount of parameter or data type of SP ? TIA, ferry

  • I get error message "The application Microsoft Word can't be opened -1712

    I have OS X 10.7.5 and MS Office 2008, and suddenly cannot open any documents or Microsoft Word. Help!