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 » Cardinality check against Env.Vars not working

Post new topic  Reply to topic
 Cardinality check against Env.Vars not working « View previous topic :: View next topic » 
Author Message
mmarq
PostPosted: Wed Nov 06, 2002 2:43 pm    Post subject: Cardinality check against Env.Vars not working Reply with quote

Acolyte

Joined: 19 Sep 2002
Posts: 74
Location: Newton, MA

Below is the data that I have in Environment.Variables.DefaultValues:

(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'suffix_3_nm '
(0x3000000)CLI_ATR_DFL_VL_TX = 'NA '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'tax_id '
(0x3000000)CLI_ATR_DFL_VL_TX = 'NA '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'tax_id_type_cd '
(0x3000000)CLI_ATR_DFL_VL_TX = 'U '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'telephone_nbr '
(0x3000000)CLI_ATR_DFL_VL_TX = 'NA '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'town_nm '
(0x3000000)CLI_ATR_DFL_VL_TX = 'NA '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'town_nm_display '
(0x3000000)CLI_ATR_DFL_VL_TX = 'NA '
)
(0x1000000)DefaultValues = (
(0x3000000)CLI_ATR_NM = 'update_dt '
(0x3000000)CLI_ATR_DFL_VL_TX = '12/31/9999


I need to iterate through the list and if a certain attribute off of DefaultValues equals something I'm looking for, take it.


I have the following:

--WHILE I < CARDINALITY(Environment.Variables.DefaultValues.*[]) DO
--if Environment.Variables.DefaultValues[I].CLI_ATR_NM = 'suffix_1_nm' THEN
--set CF.contact admin.suffix1 = Environment.Variables.DefaultValues.[I].CLI_ATR_DFL_VL_TX;
--END IF;
--END WHILE;

I have two problems.

1. This goes into an infinite loop.
2. And the following cardinality check produce the value 2 telling me that is sees only 2 DefaultValues instances

set Environment.Variables.CARDINALOFRefData = CARDINALITY(Environment.Variables.DefaultValues.*[]);

Any clues?

Thanks,
Melissa
_________________
M Marquis
Back to top
View user's profile Send private message Visit poster's website AIM Address
migstr
PostPosted: Wed Nov 06, 2002 4:18 pm    Post subject: Reply with quote

Apprentice

Joined: 05 Jun 2002
Posts: 34
Location: New York

Hi,
I think this should be:
CARDINALITY(Environment.Variables.DefaultValues[])


I'm going to provide a sample for you using SELECT instead. Hope this helps:
mydata--
(0x1000000)Variables = (
(0x1000000)PARMS = (
(0x3000000)PARM_NAME = 'CLIENT'
(0x3000000)PARM_VALUE = '115'
)
(0x1000000)PARMS = (
(0x3000000)PARM_NAME = 'PORT'
(0x3000000)PARM_VALUE = '1000'
)
)

IF CARDINALITY(Environment.Variables.PARMS[])=0 THEN
THROW USER EXCEPTION MESSAGE 2951 VALUES('NO PARMS FOUND');

SET OutputRoot.XML.MESSAGE.TEST.CLIENT = THE(SELECT ITEM T.PARM_VALUE
FROM Environment.Variables.PARMS[] AS T
WHERE T.PARM_NAME = 'CLIENT');
Back to top
View user's profile Send private message
wmqiguy
PostPosted: Thu Nov 07, 2002 5:57 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 145
Location: Florida

I'll also throw something out there. If that is a direct cut and paste of your code, then you are not incrementing your counter I.

I have done this before while in a rush.

Otherwise, I would do the following:

1. Comment out the loop.
2. Assign the return of cardinality to a variable.
3. Run a trace and see what value it is returning.

Good luck.

Todd
Back to top
View user's profile Send private message
mmarq
PostPosted: Thu Nov 07, 2002 6:11 am    Post subject: Reply Reply with quote

Acolyte

Joined: 19 Sep 2002
Posts: 74
Location: Newton, MA

Ahhhh - I didn't realize that I could use SELECT in that way. Cool!
Thanks for the advice - it makes it much cleaner.

Regarding the second reply - I don't need to increment my counter as I am working from the top of the list to the bottom (or 1). I also did what you suggested in #2 - see what CARDINALITY is returning and it was 2 when it should have been more like 10. Thanks for the reply.

Regarding the code too, I took the CARDINALITY check out of the while loop as this is a classic insufficiency in code. The CARDINALITY check should be done once outside the WHILE. Of course, the code sample I got was from the code you get when you select 'Copy Message Headers'.

Anywho, thanks all for the replies.

-Melissa
_________________
M Marquis
Back to top
View user's profile Send private message Visit poster's website AIM Address
wmqiguy
PostPosted: Thu Nov 07, 2002 6:12 am    Post subject: Reply with quote

Centurion

Joined: 09 Oct 2002
Posts: 145
Location: Florida

And like Columbo....just one more thing:

I notice that you are counting the number of elements under the first DefaultValue. You should be counting (I prefer a select statement, a bit faster):


SET I = 1;
SET MY_COUNT = (SELECT COUNT(*) FROM InputLocalEnvironment.Variables.DefaultValues[] AS M);


WHILE I <= MY_COUNT DO

Your code here


SET I = I + 1;
END WHILE;

Also, cardinality is expensive to put in the while statement if your list is very long. That is because for each loop it must be carried out and it will have to walk the tree. If you just assign to variable, it will only have to walk the tree once and then have a variable to reference to for each occurence.

Hope that helps!

Todd
Back to top
View user's profile Send private message
mmarq
PostPosted: Thu Nov 07, 2002 8:10 am    Post subject: Reply Reply with quote

Acolyte

Joined: 19 Sep 2002
Posts: 74
Location: Newton, MA

So here is my tree:

(0x1000000)DefaultValues = (
(0x3000000)Column0 = 'telephone_nbr'
(0x3000000)Column1 = 'NA'

SET CF.contact admin.tele = THE(SELECT ITEM T.Column1
FROM Environment.Variables.DefaultValues[] AS T
WHERE T.Column0 = 'telephone_nbr');

And the setting I get back is:
contact admin.tele=''

It doesn't pick up the value. Any ideas? I'm expecting to get 'NA'

Thanks,
Melissa
_________________
M Marquis
Back to top
View user's profile Send private message Visit poster's website AIM Address
migstr
PostPosted: Wed Nov 13, 2002 7:13 am    Post subject: Reply with quote

Apprentice

Joined: 05 Jun 2002
Posts: 34
Location: New York

Hi, Are you still having a problem with this? I don't see the Variables parent in your tree, did you just forget to cut and paste?
I just ran mine again and it works fine. Where are you populating your Environment Tree?
I'll give you an example of how I populate it in a previous database node. Then in the next Compute node I go after the values with the select:

DATABASE NODE:
SET Environment.Variables.PARMS[]=
(SELECT T.APPLICATION_ID, T.PARM_NAME, T.PARM_VALUE FROM Database.XXX001 AS T
WHERE T.APPLICATION_ID='APPLICATION') ;

Compute Node:
SET OutputRoot.XML.MESSAGE.APPL.CLIENT = THE(SELECT ITEM T.PARM_VALUE
FROM Environment.Variables.PARMS[] AS T
WHERE T.PARM_NAME = 'CLIENT');
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 » Cardinality check against Env.Vars not working
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.