473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

SQL statement parsing

Hi folks,

In case the SQL statement is not written properly, we sometimes get strange
messages. The 2 following statements are simple inversion between order by
and group by clause. We get an "advice" about expected from or from_clause,
why ?

db2 select workdept, count(*) from employee order by 1 group by workdept
SQL0104N An unexpected token "select workdept, count(*) from employ" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from_clause>". SQLSTATE=42601

db2 select workdept, count(*) from employee order by workdept group by
workdept
SQL0104N An unexpected token "select workdept, count(*) from employee orde"
was found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from>". SQLSTATE=42601
Regards,

Jean-Marc
Jan 11 '06 #1
1 3253
Jean-Marc Blaise wrote:
Hi folks,

In case the SQL statement is not written properly, we sometimes get strange
messages. The 2 following statements are simple inversion between order by
and group by clause. We get an "advice" about expected from or from_clause,
why ?

db2 select workdept, count(*) from employee order by 1 group by workdept
SQL0104N An unexpected token "select workdept, count(*) from employ" was
found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from_clause>". SQLSTATE=42601

db2 select workdept, count(*) from employee order by workdept group by
workdept
SQL0104N An unexpected token "select workdept, count(*) from employee orde"
was found following "BEGIN-OF-STATEMENT". Expected tokens may include:
"<from>". SQLSTATE=42601

The GROUP BY clause has to come before the ORDER BY.
So the -104 (syntaxerror) is expected (the tokens are not terribly
useful I admit)

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab
Jan 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Max Skaller | last post by:
please reply to skaller@ozemail.com.au (I don't read this newsgroup, and the reply-to address is fake) For some time now -- over 5 years -- I have been using the interscript literate programming...
3
by: Phil | last post by:
Hei, I'm currently trying to write a program in C# that will allow users to parametrize their queries. For instance, I have a query like this: SELECT * FROM Customers Where Region = @Region AND...
6
by: BerkshireGuy | last post by:
Does anyone know of a good function that will parse out parts of an SQL statement that is passed to it in seperate variables? It should be able to parse statements that contain ORDERBY, WHERE,...
2
by: robert kurz | last post by:
hallo ng, i am trying to parse a sql-statement with regular expressions. my goal is to get the parts of the statement. in my thoughts the group-functionality of the regular expressions should do...
2
by: SR | last post by:
Hello: I have some question on DB2 SQL Statement Cache. In the Oracle world, we allways use bind variables extensively, otherwise, Oracle does not re-use the statement cache, and there by...
2
by: Peter Michaux | last post by:
Hi, I am reading the ECMAScript specs trying to figure out if the next line is a legal statement or not new Foo(); I think the above code may only be legal as an expression and not as a...
6
by: Kbalz | last post by:
Trying to run a simple query on my dataset the SQL statement looks like this: select * from person where id in (@p) When using more than one id in the "in statement", I get...
23
by: florian.loitsch | last post by:
According to the spec Section 14 the production SourceElements:SourceElements SourceElement is evaluated as follows: 1. Evaluate SourceElements. 2. If Result(1) is an abrupt completion, return...
3
by: Joshepmichel | last post by:
Please to help me to following problem I want to do this 1. create Table Name MEMBER on the Database Name "mytestdb", 2. Add the Values to the Table through the Key board Inputs during running...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.