Solved

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

Posted on 2014-03-12
9
746 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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 45

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  â€¦
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

706 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

22 Experts available now in Live!

Get 1:1 Help Now