Posted: Thu Dec 21, 2006 8:54 am Post subject: Complete noob SELECT into a variable question...
Newbie
Joined: 07 Dec 2006 Posts: 8
Hi all,
I'm brand new to MQ and Websphere, trying to learn as I code. I'm looking and I don't see an example in the ESQL docs or in my searches in the forum for what I'm trying to do. Should be simple...and I guess I'm missing something. I'm trying to set the value of a variable I declared to a value I'm selecting from a DB2 database.
In the editor, it says I have a syntax error...and I can't seem to find it. (I've not gotten to the part of actually running this yet.
Here's the basics:
DECLARE v_database NAME 'TESTDB';
DECLARE V_LOCATION CHARACTER;
And this line gets the syntax error:
SET V_LOCATION = (SELECT X.KEY1_FLD_VAL FROM Database.v_database.REF_TBL AS X WHERE BUSINESS_UNIT='KR828' AND MAPNAME = 'Location Lookup' AND KEY1 = InputRoot.XML.DATASET.ROWSET.RECORD[<]);
This query WILL only return one value. Can someone spot the syntax error?
Suggestions and links to info greatly appreciated!!
Also you must use table prefix to distinguish database fields from local variables.
Code:
SET V_LOCATION =
THE (SELECT ITEM X.KEY1_FLD_VAL
FROM Database.v_database.REF_TBL AS X
WHERE X.BUSINESS_UNIT='KR828'
AND X.MAPNAME = 'Location Lookup'
AND X.KEY1 = InputRoot.XML.DATASET.ROWSET.RECORD[<]);
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