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 » Fetching a rows from DB2 which are changed in last 7 days

Post new topic  Reply to topic
 Fetching a rows from DB2 which are changed in last 7 days « View previous topic :: View next topic » 
Author Message
Siddu
PostPosted: Tue Dec 04, 2012 3:28 am    Post subject: Fetching a rows from DB2 which are changed in last 7 days Reply with quote

Apprentice

Joined: 22 Aug 2012
Posts: 44

Hi All,
I'm trying to fetch the records from DB2 which have been changed in last 7 days.
My Query looks like like this:
SET Environment.XMLNSC.Result.AppAudit1[] = (SELECT T.* FROM Database.{DSNNAME2}.{DBSCHEMA2}.{DBTABLE2} AS T WHERE ROW CHANGE TIMESTAMP FOR T <= CURRENT TIMESTAMP AND ROW CHANGE TIMESTAMP FOR T >= CURRENT TIMESTAMP - 7 DAYS);

But it is saying syntax error.

Is it allowed to use DB2 keywords directly in esql or we need to modify the statements?
Please someone guide me on this...
_________________
"Be honest. It is one of the few things that you can control in your life."
Back to top
View user's profile Send private message
kash3338
PostPosted: Tue Dec 04, 2012 3:59 am    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

Try running this query using PASSTHRU
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Tue Dec 04, 2012 4:27 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

kash3338 wrote:
Try running this query using PASSTHRU


Make sure to alter the syntax of it to remove the ESQL specific parts and ensure it is compliant with the version of SQL that is in force in your database.
Back to top
View user's profile Send private message
Siddu
PostPosted: Tue Dec 04, 2012 4:31 am    Post subject: Reply with quote

Apprentice

Joined: 22 Aug 2012
Posts: 44

kash3338 wrote:
Try running this query using PASSTHRU


Hi Kash,
Thanks for the response.
Itried this:
SET MyQry = 'SELECT T.* FROM TABLE dbo.tblPESDelta AS T WHERE T.DTTM_Stamp >= T.DTTM_Stamp - INTERVAL 5 DAY';
SET Environment.XMLNSC.Result.AppAudit1[] = PASSTHRU (MyQry) TO Database.DSNNAME2;

I also tried below one:

SET Environment.XMLNSC.Result.AppAudit1[] = PASSTHRU 'SELECT T.* FROM TABLE dbo.tblPESDelta AS T WHERE T.DTTM_Stamp >= T.DTTM_Stamp - INTERVAL 5 DAY' TO Database.DSNNAME2;

But still getting the error saying:
Syntax error. Valid options include : ||/=>= etc.

Where syntax is wrong... I went through Info centre but still couldn't find the solution...
_________________
"Be honest. It is one of the few things that you can control in your life."
Back to top
View user's profile Send private message
JosephGramig
PostPosted: Tue Dec 04, 2012 7:13 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

Did you get the query to work in the DB2 product itself first? Like at the DB2 command prompt...
Back to top
View user's profile Send private message AIM Address
smdavies99
PostPosted: Tue Dec 04, 2012 7:34 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

I'd probably sort out the interval first and supply that to the query.

AFAIK, INTERVAL does not easily translate into DB2 SQL.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
kash3338
PostPosted: Tue Dec 04, 2012 7:58 am    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

smdavies99 wrote:
AFAIK, INTERVAL does not easily translate into DB2 SQL.




Infact DB2 does not support INTERVAL datatype. Below quote from one of IBM's infocenter says that,

Quote:
INTERVAL — DB2 does not support an equivalent type, but does support date and time labelled durations for manipulating DATE, TIME, and TIMESTAMP values and generating date and time intervals.
Back to top
View user's profile Send private message Send e-mail
JosephGramig
PostPosted: Tue Dec 04, 2012 8:13 am    Post subject: Reply with quote

Grand Master

Joined: 09 Feb 2006
Posts: 1244
Location: Gold Coast of Florida, USA

Since you are using PASSTHRU, you need to use the syntax of the database service you are PASSingTHRU to. It is sent to the database service as is for interpretation same as if you were at the DB2 prompt (for DB2 for instance).
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Fetching a rows from DB2 which are changed in last 7 days
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.