Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / January 2006

Tip: Looking for answers? Try searching our database.

SQL statement parsing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jean-Marc Blaise - 11 Jan 2006 21:23 GMT
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
Serge Rielau - 11 Jan 2006 22:11 GMT
> Hi folks,
>
[quoted text clipped - 13 lines]
> 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
Signature

Serge Rielau
DB2 Solutions Development
DB2 UDB for Linux, Unix, Windows
IBM Toronto Lab

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.