Author |
Message
|
archana |
Posted: Wed Mar 29, 2006 12:58 am Post subject: Copy query result to a variable |
|
|
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 |
|
 |
shalabh1976 |
Posted: Wed Mar 29, 2006 1:14 am Post subject: |
|
|
 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 |
|
 |
archana |
Posted: Wed Mar 29, 2006 2:21 am Post subject: Copy query result to variable |
|
|
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 |
|
 |
mgk |
Posted: Wed Mar 29, 2006 2:29 am Post subject: |
|
|
 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 |
|
 |
n1ghtrain |
Posted: Wed Mar 29, 2006 2:29 am Post subject: |
|
|
 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 |
|
 |
n1ghtrain |
Posted: Wed Mar 29, 2006 2:49 am Post subject: |
|
|
 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 |
|
 |
archana |
Posted: Wed Mar 29, 2006 4:02 am Post subject: copy query results to a variable |
|
|
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 |
|
 |
archana |
Posted: Fri Mar 31, 2006 1:58 am Post subject: how to retrieve an integer value from a table |
|
|
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 |
|
 |
|