Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-03-12
9
832 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
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: 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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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.  …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

809 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