ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Syntax error in esql for sql queries with top, order by

Post new topic  Reply to topic
 Syntax error in esql for sql queries with top, order by « View previous topic :: View next topic » 
Author Message
kpravin
PostPosted: Fri Jan 23, 2015 5:34 am    Post subject: Syntax error in esql for sql queries with top, order by Reply with quote

Newbie

Joined: 21 Jan 2011
Posts: 3

Hi,
I have to run a sql query in esql as below, but it fails with syntax error.

Simple select query works fine.

Can you please check and help in syntax error for below sql query.

select top(1) employeeId, amount ,paidamount from dbname.schema.tablename
where [deliveryStatus ]= 'Pending'
and employeeId = '12345'
order by creationDate desc

Regards,
Pravin
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 23, 2015 5:36 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That's an SQL select statement.

It's not an ESQL select statement.
Back to top
View user's profile Send private message
vrboya
PostPosted: Fri Jan 23, 2015 9:21 am    Post subject: Reply with quote

Newbie

Joined: 20 Jul 2013
Posts: 7

Try to run the sql query use a PASSTHRU code

Syntax looks something like this

DECLARE cSQLQuery CHARACTER;
SET cSQLQuery = 'select top(1) employeeId, amount ,paidamount from dbname.schema.tablename
where [deliveryStatus ]= 'Pending'
and employeeId = '12345'
order by creationDate desc

SET Environment.Variables.MetaInfo.SqlResult[] = PASSTHRU (cSQLQuery);

Your query results will be in an array form in the environment variables.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jan 23, 2015 10:45 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

vrboya wrote:
Try to run the sql query use a PASSTHRU code


Ah, good point. I missed the order by clause. ESQL Select doesn't support ORDER BY or GROUP BY.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Syntax error in esql for sql queries with top, order by
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.