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 » SQL Query construction

Post new topic  Reply to topic
 SQL Query construction « View previous topic :: View next topic » 
Author Message
SpitFire
PostPosted: Thu Jan 19, 2006 11:30 pm    Post subject: SQL Query construction Reply with quote

Acolyte

Joined: 01 Aug 2005
Posts: 59
Location: India

Hi all,
In one of my message flows (designed in WBIMB V5.0 CSD-5), I'm trying to retrieve an information from an incoming message and then query the database and then construct the outgoing message accordingly. I'm facing multiple problems in this regard.
I have quoted them all here and please help me in resolving them.

Message Structure: XML

- Incoming Message -
<Request>
<Items>
<ItemNumber> </ItemNumber>
<RequiredInfo> NAME/ORIGIN/PLACE </RequiredInfo>
</Items>
</Request>

- Outgoing Message -
<Response>
<Items>
<ItemNumber>
</ItemNumber>
<SuppliedInfo> NAME/ORIGIN/PLACE </RequiredInfo>
</Items>
</Response>

SQL query:
--------------------------------------------------------------------------------
WHILE Index <= CARDINALITY(InputRoot.MRM.Items[])
IF InputRoot.MRM.Request.Items[Index].RequiredInfo = 'NAME' THEN
SET OutputRoot.MRM.Response.SuppliedInfo[PartIndex].PART_INFO
VALUE =
THE(SELECT ITEM COALESCE(T.NAME, 'NULL') FROM
Database.TAB_SOME_TABLE AS T
WHERE
T.ITEM_NUM
LIKE
InputRoot.MRM.Request.Items[Index].ItemNumber);
END IF;
Index = Index + 1;
END WHILE;
--------------------------------------------------------------------------------

[1] I don't know how to retrieve the result of an SQL query and store the answer in a scalar value. The above query fails with the error 'Invalid Field Reference'. Is my method of extracting a scalar value out of an sql query incorrect?

[2] In the same query indicated above, can I include the field name to be extracted from the resultset dynamically. What I mean is can the above query be formulated like this? The column to be extracted is dependent on the value of - "InputRoot.MRM.Items[Index].RequiredInfo".

Modified - SQL query:
--------------------------------------------------------------------------------
WHILE Index <= CARDINALITY(InputRoot.MRM.Items[])
IF InputRoot.MRM.Request.Items[Index].RequiredInfo = 'NAME' THEN
SET OutputRoot.MRM.Response.SuppliedInfo[PartIndex].PART_INFO
VALUE =
THE(SELECT ITEM COALESCE(<<Required Info>>, 'NULL') FROM
Database.TAB_SOME_TABLE AS T
WHERE
T.ITEM_NUM
LIKE
InputRoot.MRM.Request.Items[Index].ItemNumber);
END IF;
Index = Index + 1;
END WHILE;
--------------------------------------------------------------------------------
_________________
...: 5|71+ph1|23 :...


Last edited by SpitFire on Fri Jan 20, 2006 12:08 am; edited 1 time in total
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu Jan 19, 2006 11:57 pm    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi _z33,

For your first problem:
1. Are you sure every occurance of your Items has a ItemNumber field ?
2. Should the reference be InputRoot.MRM.Request.Items.....?

For you second problem:
I dont think you can use the field value to refer to the column, but I could be wrong...You should try it...
It'll have to be
Code:
THE(SELECT ITEM COALESCE(T."InputRoot.MRM.Items[Index].RequiredInfo", 'NULL') FROM


Best of luck.

Regards.
Back to top
View user's profile Send private message Send e-mail
SpitFire
PostPosted: Fri Jan 20, 2006 12:16 am    Post subject: Clarification- SQL query construction Reply with quote

Acolyte

Joined: 01 Aug 2005
Posts: 59
Location: India

Hi elvis_gn,

elvis_gn wrote:

For your first problem:
1. Are you sure every occurance of your Items has a ItemNumber field ?
2. Should the reference be InputRoot.MRM.Request.Items.....?


Regarding your first point, yes I'm very sure that every item has an itemnumber. And as far as the second one is considered, I have updated my post accordingly, and I hope that clarifies your doubt.

elvis_gn wrote:

For you second problem:
I dont think you can use the field value to refer to the column, but I could be wrong...You should try it...
It'll have to be
Code:
THE(SELECT ITEM COALESCE(T."InputRoot.MRM.Items[Index].RequiredInfo", 'NULL') FROM



I shall try the method cited and shall revert back if there is any problems. Thanks for the pointers.
_________________
...: 5|71+ph1|23 :...
Back to top
View user's profile Send private message
dipankar
PostPosted: Fri Jan 20, 2006 12:47 am    Post subject: Reply with quote

Disciple

Joined: 03 Feb 2005
Posts: 171

Hi_z33,

Code:
WHILE Index <= CARDINALITY(InputRoot.MRM.Items[])


it will return zero value

your code should be
Code:
WHILE Index <= CARDINALITY(InputRoot.MRM.Request.Items[])


Please check your input message.
Also check
SET OutputRoot.MRM.Response.SuppliedInfo[PartIndex].

Waht is the value of PartIndex?

Check your ESQL carefully
_________________
Regards
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Fri Jan 20, 2006 12:56 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi _z33,

Quote:
I have updated my post accordingly, and I hope that clarifies your doubt.


That wasn't my doubt, or atleast I was trying to indicate that error in code.
That is the mistake you had made and are getting Invalid field reference for....

Second one, let us know if you got it fixed.

Regards.
Back to top
View user's profile Send private message Send e-mail
SpitFire
PostPosted: Fri Jan 20, 2006 5:39 am    Post subject: [AVERTED] SQL Query Construction Reply with quote

Acolyte

Joined: 01 Aug 2005
Posts: 59
Location: India

Hi elvis_gn,

elvis_gn wrote:

For you second problem:
I dont think you can use the field value to refer to the column, but I could be wrong...You should try it...
It'll have to be
Code:

      THE(SELECT ITEM COALESCE(T."InputRoot.MRM.Items[Index].RequiredInfo", 'NULL') FROM
      



You are right, I am not able to use field value to refer to the column.
And for the first, I had just overlooked what I had posted. The 'invalid field reference' error was not because of that. In the query if you can see there is a comparison. And the compared value is of type 'character' and therefore when the query is constructed since the single quote is missing, I was facing the problem. This is just a guess, and I could be really blabbering. I was able to try otherwise to retrieve a scalar value out of the value returned by a result set. Thanks for all the help.
Anyway, I have averted the problem because my problem requirements have changed. I'm still however in pursuit of finding a solution for my second problem, so anyone if there is a method/hack, do please post.
_________________
...: 5|71+ph1|23 :...
Back to top
View user's profile Send private message
SpitFire
PostPosted: Fri Jan 20, 2006 5:48 am    Post subject: Reply with quote

Acolyte

Joined: 01 Aug 2005
Posts: 59
Location: India

Hi,
dipankar wrote:


Code:
WHILE Index <= CARDINALITY(InputRoot.MRM.Items[])


it will return zero value



The point is that "till now" it is not returning an error. Anyways, I've changed that properly to reflect what had suggested, a little while ago itself. Nevertheless, I am able to safely ignore the outermost container/tag name everywhere in ESQL. Am I overlooking something here?

dipankar wrote:

Please check your input message.
Also check
SET OutputRoot.MRM.Response.SuppliedInfo[PartIndex].

Waht is the value of PartIndex?

Check your ESQL carefully


'TYPO' - I guess
_________________
...: 5|71+ph1|23 :...
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 » SQL Query construction
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.