Sitemap

Amicuk Programming Answers

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

2015-10-11   Views:0

Advertisement

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=:contrac

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.

The replay answer
Advertisement
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

Go to See the other 5 answers

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

Category:DefaultRelease time:2015-10-11Views:130

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=:contrac[More]

Query getting  /crystal/ Program SYNTAX ERROR.

Category:DefaultRelease time:-0001-11-30Views:130

Hi All, I connected to SAP BEX Query using MDX driver. when i execute query getting  /crystal/ Program SYNTAX ERROR. I imported these  crystal transports R21900741,786,695,754,780 . but got error for R71K900087 . MY SAP BW system version is SAP BW701[More]

This query eithr has a syntax error or is using features of the langauage not suported in design view

Category:DefaultRelease time:-0001-11-30Views:130

can anybody tell me what's wrong with this, please: SELECT DISTINCT SMS_R_SYSTEM.ResourceID, SMS_R_SYSTEM.ResourceType, SMS_R_SYSTEM.Name, SMS_R_SYSTEM.SMSUniqueIdentifier, SMS_R_SYSTEM.ResourceDomainORWorkgroup, SMS_R_SYSTEM.Client FROM sms_r_system[More]

InfoSet Query: Syntax Error while generating the program.

Category:DefaultRelease time:2015-10-11Views:130

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 fo[More]

Improving a simple Query

Category:DefaultRelease time:-0001-11-30Views:130

Following is a simple query, what i want to know, i have added upper select to get d.name which is the description of region_code. Can i get whole result with single select SELECT t.region_code,d.name, t.emp_contr FROM (SELECT c.br_region_fo_code as[More]

Simple query takes time to run

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a simple query whcih takes about 20 mins to run.. here is the TKPROF forit:   SELECT     SY2.QBAC0,     sum(decode(SALES_ORDER.SDCRCD,'USD', SALES_ORDER.SDAEXP,'CAD', SALES_ORDER.SDAEXP /1.0452))   FROM     JDE.F5542SY2  SY2,     JDE.F4211[More]

How to write a simple query.

Category:DefaultRelease time:2015-10-11Views:130

I have a table where I have data shown below. Now, I want to write a simple query which lists me the project and the count of the distinct effective dates for which data is existant there. Sample data: Project Task Effective Date (xx_proj_task_data)[More]

Simple Query in Oracle Linked Table in MS Access causes full table scan.

Category:DefaultRelease time:2015-10-11Views:130

I am running a very simple query in MS ACCESS to a linked Oracle table as follows: Select * From EXPRESS_SERVICE_EVENTS --(the linked table name refers to EXPRESS.SERVICE_EVENTS) Where performed > MyDate() or Select * From EXPRESS_SERVICE_EVENTS --(t[More]

Error in the simple Query

Category:DefaultRelease time:2015-10-11Views:130

Dear Experts, Not able to Execute this simple query : Select T1.JobID , T1.BudgetValue,T1.ActualValue FROM [dbo].[Enprise_JobCost_ActualBudgetView] T1 WHERE T1.TransType = '[%0]' RegardsHello, View - A View in simple terms is a subset of a 'virtual t[More]

Simple Query working on 10G and not working on 11gR2 after upgrade

Category:DefaultRelease time:2015-10-11Views:130

Hi Folks, This is the first time i am posting the query in this Blog. I have a small issue which preventing the UAT Sigoff. Simple query working fine on 10.2.0.1 and after upgrade to 11.2.0.1 its error out 10.2.0.4: ===== SQL> SELECT COUNT(*) FROM AP[More]

Trying to optimize this simple query

Category:DefaultRelease time:2015-10-11Views:130

Hi, I am trying to optimize this simple query but the two methods I am trying actually make things worse. The original query is: SELECT customer_number, customer_name FROM bsc_pdt_account_mv where rownum <= 100 AND Upper(customer_name) like '%SP%' AN[More]

Hot
I physically lost an iMac when Hurricaine Katrina destroyed my house. It was the computer that had my iTunes library. I now have a new iTunes library on a Powerbook and have two iPods that are authorized. If I purchase an iPhone or a new iPod I will [More]
I want to use the back/fwd arrows to view windows, not tabs and I hate having 3 windows open.  It does this when Yahoo, Google or any other search engine is used, but if I go to a site from my bookmarks it is fine.  Maddening.  It was OK via Yahoo an [More]
Anyone can help ?Did you install the Windows Support files you downloaded from Apple when you first started Boot Camp Assistant? If not install them.Read other 3 answers [More]
So I have tried setting it to Apple DV/DVCPRO - NTSC and it will not work in Multiclip and I get no options under RT on my timeline. However if I then export from Quicktime choosing DV/DVCPRO it will work with Multiclip and I get my options under Tim [More]
All the App Tabs disappeared when I opened Firefox after quitting. I understand that the App Tabs that I had set remains there if I close the browser and not quit. So does that mean that I have to create App Tabs every time I restart FireFox?App tabs [More]
Hi When we create a custom top in oracle applications 11i/R12, is it mandatory to run autoconfig? Are there any manual entry steps to be performed in adding custom top entry other than xml file like topfile.txt????Hi, When we create a custom top in o [More]
The icon in the Dock has changed. It is now a stack of two white sheets of paper with a paintbrush, ruler, and penicil on them. When I click on it, it bounces once, and nothing opens. I miss Mail! Thanks.It looks like you didn't install the latest up [More]
Hi ABAP Gurus, Iam phaneendra can anybody explain in detail what happens when there is an error record exist while updating a session in session method and in call transaction. ie, out of 10 records 7th one is error let it be then what happens to 6 r [More]
I am new to Dreamweaver CS6 and trying to do  a website for a charity . They require to update and add photos to their website. Some one suggested wordpress.I want to design it in dreamweaver but can anyone suggest how to intergrate wordpress with Dr [More]
I can not access to icloud. Whenever i try it, the message says there is too much entry from the same phone. How can i delete the old accounts?See answer here: https://discussions.apple.com/message/21828039#21828039.Read other 2 answers [More]