Solved

What am I missing with this error:  ORA-00936: missing expression

Posted on 2014-03-12
9
776 Views
Last Modified: 2014-11-03
This is the sequel statement that I have in Microsoft Query and it works fine:  

SELECT SO.DEL_DOC_NUM, SO.SHIP_TO_ZIP_CD, Sum(SO_LN.UNIT_PRC*qty)
FROM SALES.SO SO, SALES.SO_LN SO_LN
WHERE SO_LN.DEL_DOC_NUM = SO.DEL_DOC_NUM AND ((SO.STAT_CD<>'V') AND (SO_LN.VOID_DT Is Null))
GROUP BY SO.DEL_DOC_NUM, SO.SHIP_TO_ZIP_CD, SO.PU_DEL, SO.PU_DEL_DT, SO.SHIP_TO_ZONE_CD, SO.ORD_TP_CD
HAVING (SO.PU_DEL='D') AND (SO.PU_DEL_DT Between {ts '2013-05-01 00:00:00'} And {ts '2013-05-31 00:00:00'}) AND (SO.SHIP_TO_ZONE_CD='HNO') AND (SO.ORD_TP_CD='SAL')

But as soon as I want the statement to allow me to enter data for the dates or the zone cd, I receive the error ORA-00936: missing expression.

I don't know what to look for or how to add an expression to this statement as I'm not writing the code, but instead selecting the fields like through a wizard.
0
Comment
Question by:drozeveld
9 Comments
 
LVL 23

Expert Comment

by:David
ID: 39924173
In Oracle the function syntax for {ts '2013-05-01 00:00:00'} is TO_DATE('2013-05-01','YYYY-MM-DD').

Secondly I suspect, without yet checking, that the GROUP BY may only include columns to the left of the function SUM().

The easiest way to parse where the error occurs -- is to execute the statement in SQL*Plus.  You'll see an asterisk character beneath the offending syntax, working right to left.
0
 
LVL 1

Author Comment

by:drozeveld
ID: 39924233
I just tried taking the items to the right of SUM function away, and my error did not go away.
0
 
LVL 23

Expert Comment

by:David
ID: 39924241
And changing the {ts....?
0
 
LVL 1

Author Comment

by:drozeveld
ID: 39924275
In Microsoft Query, I always use the "wizard" type of input.  When I want a date range, I've always changed the "filter" to:  BETWEEN and then in the box below I've entered [begdate],[enddate].  By doing this, a pop-up box appears and I have to enter the date like:  01-may-13.

With that being said, I'm a little lost on how to change the to TO_DATE to be able to require the pop-up boxes so that I can enter the date ranges I want to see.

I've attached a screen shot of what I'm looking at.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 1

Author Comment

by:drozeveld
ID: 39924279
Here is the screenshot
MSQ-SCREENSHOT.tif
0
 
LVL 10

Accepted Solution

by:
dbmullen earned 500 total points
ID: 39933339
I hate to do this but this sounds more like a "mircosoft query" question than an Oracle question.  I did a google search for
"microsoft query oracle date variable"
http://www.mrexcel.com/forum/excel-questions/27292-resolved-oracle-date-time-parameter-msquery.html

what your "query" above has is a "string"
 {ts '2013-05-01 00:00:00'}

something needs to tell oracle that it's really a "date"...  thus, the "to_date" response.
0
 
LVL 1

Author Comment

by:drozeveld
ID: 39938059
You are correct.  This is probably Microsoft Query, instead of Oracle.  I apologize for incorrectly coding.

Thank you for the link to the Mr. Excel thread.  I think that will help me get this figured out.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40419082
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now