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
HI, I have combed previous discussions and tried the suggestions.  I am running OS X 10.9.2.  My Epson software is current( I just re downloaded all the drivers etc.) I uninstalled and reinstalled my printer.  I opened sharing and there is a name the [More]
i have been trying to set up file sharing so I can move files on my windows PC (music, pic's, office, pdf, etc..) to my new MBP.  I followed all the directions, but still cannot see the MBP on the PC.  I had it working a few days ago by setting up th [More]
Hi, I have created a table control in module pool. I have pasted fields from internal table and I have also added text to its header But when I execute the program text is not shown in the header.It is appearing blankHi Srini , IF you are using the B [More]
Hi all, i want to create a checklist for rpd..that tells about what are all the best practices that we have to do.. we have to write some script based on this script only it has to create the checklist. Thanks in advance Edited by: 988084 on 13/05/20 [More]
Well, when one has been removed from Snow Leopard's Preview (remember that "Tools > Match To-" menu?) I thought that maybe it'll be back in Lion but magics so hyped by Apple didn't happen - Lion still has no way to convert RGB images into CMY [More]
some vedio ok and some of them appear black boxuser12175789 wrote: dear all, I face one problem when i want run oracle 9i in my computer, when i open enterprise and i want open my database their one massage it come it return ( your database curnntly [More]
Hi, I can´t create a workspace, the error is: ORA-20001: Request 4546231368762012 could not be processed. -20001 ORA-20001: Unable to grant initial privs. ORA-20001: Error with: GRANT CREATE CLUSTER TO "USER" ORA-01031: insufficient privileges t [More]
Hi, I have created an item level output for Quotations. My requirement is that this output should print only the items that I have selected in the quotation. eg: If my quotation has 10 line items and I have trigerred item level output for 5 line item [More]
Any ideas how to NOT USE errdisable or allow the FCoE switch to put a port / interface / VFC  into an error disabled state? I do not see any command(s) to NOT use this feature. thanks mattYou can disable errordisable condition only for certain causes [More]
J 'ai non Fichier de 3 pages, Je Veux Supprimer en une ! comment faire?Adobe Reader cannot edit PDF files; you need Acrobat for that.Read other 2 answers [More]