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 » Copy query result to a variable

Post new topic  Reply to topic
 Copy query result to a variable « View previous topic :: View next topic » 
Author Message
archana
PostPosted: Wed Mar 29, 2006 12:58 am    Post subject: Copy query result to a variable Reply with quote

Newbie

Joined: 29 Mar 2006
Posts: 5

I want to know how using ESQL , can i copy the result of the query to a variable.

Say suppose i have a date in the table. I want to extract the date from the table and compare it with the current date.

Eg: select date from table 1.
My problem is i am able to move the value only to OutputRoot.

eg: OuputRoot.msg.out= eval('(select * from table'));
this is working fine.

how do i move the same to a esql variable.

eg: declare var;
var = [ how to set it here]
Back to top
View user's profile Send private message
shalabh1976
PostPosted: Wed Mar 29, 2006 1:14 am    Post subject: Reply with quote

Partisan

Joined: 18 Jul 2002
Posts: 381
Location: Gurgaon, India

You can move anything to the variable, however you must be careful to move a list item to list only and a non list to non list.
In your case the SELECT * can return multiple values and then trying to assign it to a single var will be a problem. Using an array/ list is the way out in this case.
_________________
Shalabh
IBM Cert. WMB V6.0
IBM Cert. MQ V5.3 App. Prog.
IBM Cert. DB2 9 DB Associate
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
archana
PostPosted: Wed Mar 29, 2006 2:21 am    Post subject: Copy query result to variable Reply with quote

Newbie

Joined: 29 Mar 2006
Posts: 5

The value is being copied but the same is not being placed in the XML tag when it is placed in the output queue.......
Back to top
View user's profile Send private message
mgk
PostPosted: Wed Mar 29, 2006 2:29 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

One, you do NOT need to use EVAL to use SELECT, and really you should avoid EVAL wherever you can.

Two, Look at the THE and ITEM clauses of SELECT in the docs, as these allow you to return a single scalar value from a SELECT that can be assigned to a variable. However, you must specify your SELECT such that it is selecting the column you want to get the variable from. I think there is an example in the docs.

Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
n1ghtrain
PostPosted: Wed Mar 29, 2006 2:29 am    Post subject: Reply with quote

Apprentice

Joined: 23 Mar 2006
Posts: 48
Location: Bangalore

Before casting string to DATE or TIME type you have to make sure your string confirms to the rule for a DATE or TIME literal/string.

You will have to construct a string in format
DATE 'YYYY-MM-DD'



and then use CAST to cast it to DATE data type.

CAST(Body.xx.YY AS DATE)

Similary, time stromg meeds to be in TIME 'HH:MM:SS.mss' format.

Hope this helps.
Back to top
View user's profile Send private message Yahoo Messenger
n1ghtrain
PostPosted: Wed Mar 29, 2006 2:49 am    Post subject: Reply with quote

Apprentice

Joined: 23 Mar 2006
Posts: 48
Location: Bangalore

Guess it would be faster than implicit cast from '2006-03-29'.

am i right.??
Back to top
View user's profile Send private message Yahoo Messenger
archana
PostPosted: Wed Mar 29, 2006 4:02 am    Post subject: copy query results to a variable Reply with quote

Newbie

Joined: 29 Mar 2006
Posts: 5

Thanks a lot for all those of u who have helped me.
I tried using ITEM instad of EVAL.
I could set the query result to a variable
Back to top
View user's profile Send private message
archana
PostPosted: Fri Mar 31, 2006 1:58 am    Post subject: how to retrieve an integer value from a table Reply with quote

Newbie

Joined: 29 Mar 2006
Posts: 5

I want to retrieve an integer value from a table...
Using ITEM clause, i am not able to do it...

Pls help me
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 » Copy query result to a variable
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.