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 » Other then Case Statement

Post new topic  Reply to topic
 Other then Case Statement « View previous topic :: View next topic » 
Author Message
nu1
PostPosted: Mon Feb 23, 2004 11:12 am    Post subject: Other then Case Statement Reply with quote

Apprentice

Joined: 28 Nov 2003
Posts: 26

Hi
FOr 100 numeric Values i have to return a corresponding CHAR value.
like

001 --- January
002 ---- February
:
:
:

999----- xxxxxx

Is there a better way to handle this using other than Case statement in ESQL.


Thanks
_________________
-nu1
Back to top
View user's profile Send private message
EddieA
PostPosted: Mon Feb 23, 2004 11:23 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

A database table.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
nu1
PostPosted: Mon Feb 23, 2004 11:32 am    Post subject: Reply with quote

Apprentice

Joined: 28 Nov 2003
Posts: 26

I dont want to use a database table..
Array will not work..
As i want something like
FOR USA ---- United STates of America
MAL----- Malyasia
PAK----- Pakistan

blah blah..
_________________
-nu1
Back to top
View user's profile Send private message
Missam
PostPosted: Mon Feb 23, 2004 11:39 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

There is no array concept in MQSI
Back to top
View user's profile Send private message
JT
PostPosted: Mon Feb 23, 2004 11:56 am    Post subject: Reply with quote

Padawan

Joined: 27 Mar 2003
Posts: 1564
Location: Hartford, CT.

nu1,
not sure if the following thread regarding the row constructor is a better way, but it is an alternative worth exploring:
http://www.mqseries.net/phpBB2/viewtopic.php?t=13627&highlight=row+select
Back to top
View user's profile Send private message
martinrydman
PostPosted: Tue Feb 24, 2004 8:44 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi!

I don't agree that MQSI lacks an array concept. I've solved similar problems by popultaing the Environment tree, like this:

Code:

SET Environment.Lookup[1].Key = 'USA';
SET Environment.Lookup[1].Value = 'United States of America';

SET Environment.Lookup[2].Key = 'MAL';
SET Environment.Lookup[2].Value = 'Malaysia';

...


I can then look up the a value from the Lookup array like this


Code:

SET MyValue = THE(SELECT ITEM T.Value FROM Environment.Lookup[] AS T WHERE T.Key = 'USA')


(I didn't run the above code. Barring typos on my part, it should work. If you have problems, I'll be happy to dig out actual tested code)

You could make the whole thing even more compact (in terms of code) by writing a PROCEDURE that takes Key-Value pairs as parameters and populates the Environment tree.

Although I agree that a db table is the best way, especially since the table can be maintained without recompiling the flow.

Hope this helps

/Martin


[/code]
Back to top
View user's profile Send private message
Lisa
PostPosted: Tue Feb 24, 2004 10:53 am    Post subject: Code Reply with quote

Master

Joined: 07 Jun 2002
Posts: 287
Location: NJ

Hi Martin,
If you get a chance, can you post the code so that I can review it?

Lisa
Back to top
View user's profile Send private message Send e-mail
Missam
PostPosted: Tue Feb 24, 2004 11:17 am    Post subject: Reply with quote

Chevalier

Joined: 16 Oct 2003
Posts: 424

The Code Above wrote by martin
Quote:

SET Environment.Lookup[1].Key = 'USA';
SET Environment.Lookup[1].Value = 'United States of America';

SET Environment.Lookup[2].Key = 'MAL';
SET Environment.Lookup[2].Value = 'Malaysia';


resembles a tree structure not an array structure.there is a lot of difference between arrays and tree structures where as indexing of array starts from 0 .can we start index of tree from 0...?
Back to top
View user's profile Send private message
EddieA
PostPosted: Tue Feb 24, 2004 11:26 am    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

Quote:
can you post the code so that I can review it?

What further code do you need. The snippets show everything.

Also, unless you are pulling a number of items from this 'table' within the flow, it will be more efficient to use a CASE. The Environment is NOT maintained across messages. You will be re-building it for each message. Unless you use one of the Support Pacs to 'cache' the data.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Feb 24, 2004 12:10 pm    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

IamSam wrote:
The Code Above wrote by martin
resembles a tree structure not an array structure.there is a lot of difference between arrays and tree structures where as indexing of array starts from 0 .can we start index of tree from 0...?


Well, arrays only start at 0 in some programming languages.

But ESQL does not have arrays. All it has is trees.

The code looks like array references, but it is not the same thing at all.

You can't talk about the next sibling of an array element, or it's last child.

It is much better to only think about trees. You get a much better idea how to actually use ESQL to do what you need if you do.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
martinrydman
PostPosted: Wed Feb 25, 2004 8:56 am    Post subject: Reply with quote

Centurion

Joined: 30 Jan 2004
Posts: 139
Location: Gothenburg, Sweden

Hi!

I totally agree that we don't have arrays in a technical sense, but I maintain that we do have arrays in a conceptual sense in sofar as we can use a tree as if it is an array.

Oh well, no big deal. Only reason to use my technique would be if, for some reason, you dont want a db table, and also if you have a more complex keying scheme than the example of this thread. In the latter case, a CASE construct could be hard to understand and maintain.

Just my 25 c

/Martin
Back to top
View user's profile Send private message
simon.starkie
PostPosted: Wed Jun 17, 2009 6:00 am    Post subject: Reply with quote

Disciple

Joined: 24 Mar 2002
Posts: 180

jefflowrey wrote:
IamSam wrote:
The Code Above wrote by martin
resembles a tree structure not an array structure.there is a lot of difference between arrays and tree structures where as indexing of array starts from 0 .can we start index of tree from 0...?


Well, arrays only start at 0 in some programming languages.

But ESQL [b]does not have arrays. All it has is trees. [/b]

The code looks like array references, but it is not the same thing at all.

You can't talk about the next sibling of an array element, or it's last child.

It is much better to only think about trees. You get a much better idea how to actually use ESQL to do what you need if you do.


The above statement threw me for a loop yesterday.
But there again, it was posted quite a long time ago and maybe things have changed.
Regardless, I decided to post here to perhaps help someone else avoid the wrong conclusion.

I have an XML request containing an array called CommunicationNumbers containing multiple instances of CommunicationNumber like this:
<CommunicationNumbers>
<Communication>
<Number>5105551567</Number>
<Qualifier>HP</Qualifier>
</Communication>
<Communication>
<Number>5105551568</Number>
<Qualifier>WP</Qualifier>
</Communication>
</CommunicationNumbers>

Here is how I am doing array processing in ESQL:

DECLARE i INTEGER;
DECLARE j INTEGER;

.
.
.

-- PID Phone Number - Business
-- PDX will send multiple instances of
-- ./Message/Body/RegistrationRx/Patient/CommunicationNumbers/Communication.
-- For the instance where the
-- ./Message/Body/RegistrationRx/Patient/CommunicationNumbers/Communication/Qualifier
-- = "WP",
-- the ESB will map values to PID-14.

SET i = 1;
SET j = CARDINALITY(InputRoot.MRM.ns1:Message.ns1:Body.ns1:RegistrationRx.ns1:Patient.ns1:CommunicationNumbers.*[]);
WHILE i <= j DO
IF 'WP' = InputRoot.MRM.ns1:Message.ns1:Body.ns1:RegistrationRx.ns1:Patient.ns1:CommunicationNumbers.ns1:Communication[i].ns1:Qualifier THEN
SET workchar = InputRoot.MRM.ns1:Message.ns1:Body.ns1:RegistrationRx.ns1:Patient.ns1:CommunicationNumbers.ns1:Communication[i].ns1:Number;
END IF;
SET i = i + 1;
END WHILE;
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 17, 2009 6:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Uhm.

No, nothing has changed. And I stand by my earlier statement.

An ESQL statement like OutputRoot.MRM.FIELD[N] is not an array reference at all. It's a reference to the Nth child of OutputRoot.MRM named FIELD. This could be the Mth child, where M > N.

In order for Broker to access the Nth child, it has to navigate to the first child, and then iterate over the Next Sibling, keeping a count.

In order to then access the N+1th child, it has to start over.

Use a REFERENCE and MOVE, always. Unless you know your structures do not repeat more than about five times.
Back to top
View user's profile Send private message
simon.starkie
PostPosted: Wed Jun 17, 2009 7:01 pm    Post subject: Reply with quote

Disciple

Joined: 24 Mar 2002
Posts: 180

mqjeff wrote:
Uhm.

No, nothing has changed. And I stand by my earlier statement.

An ESQL statement like OutputRoot.MRM.FIELD[N] is not an array reference at all. It's a reference to the Nth child of OutputRoot.MRM named FIELD. This could be the Mth child, where M > N.

In order for Broker to access the Nth child, it has to navigate to the first child, and then iterate over the Next Sibling, keeping a count.

In order to then access the N+1th child, it has to start over.

Use a REFERENCE and MOVE, always. Unless you know your structures do not repeat more than about five times.


Ah, I see. Thanks for setting me straight on that.
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 » Other then Case Statement
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.