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 » Using Declare ... Reference To ...

Post new topic  Reply to topic
 Using Declare ... Reference To ... « View previous topic :: View next topic » 
Author Message
kwelch
PostPosted: Mon Apr 15, 2002 6:34 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi,

We are attempting to use the new Declare ... Reference To ... in WMQI 2.1 and find that we are unable to get it to work in an IF statement unless all of the statements that then reference this variable are also in the IF statement. A deploy error is given if we try to reference the variable outside the IF statement.

Has anyone else experienced this? Is this working as it's supposed to or is there a fix available? Thanks in advance for any help on this one.

Karen
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Mon Apr 15, 2002 7:11 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Can you post the ESQL used and the error message received. What exact release and maintenance level is being used and on what platform?
Back to top
View user's profile Send private message
kwelch
PostPosted: Mon Apr 15, 2002 8:01 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Hi Kolban,


Sure! This is just a simple example for the sake of this post, but it illustrates the issue that we are hitting. We are at CSD01 I believe and running the Broker on NT with a combination of NT/2000 Control Centers. Here is the one that works:

DECLARE I INTEGER;
SET I = 1;
WHILE I < CARDINALITY(InputRoot.*[]) DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
SET OutputRoot.Properties.MessageFormat = 'XML';

IF InputBody.TOT.MSG[1].LAST = 'WELCH' THEN
SET OutputLocalEnvironment.Variables.TOT.*[] = InputBody.TOT.*[];
DECLARE MSGNM REFERENCE TO OutputLocalEnvironment.Variables.TOT.*[];

SET MSGNM.MSG[1].LAST = 'KAREN';
SET MSGNM.MSG[1].FIRST = 'WELCH';

END IF;

Here is the one that gets the deploy error:

DECLARE I INTEGER;
SET I = 1;
WHILE I < CARDINALITY(InputRoot.*[]) DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I=I+1;
END WHILE;
-- Enter SQL below this line. SQL above this line might be regenerated, causing any modifications to be lost.
SET OutputRoot.Properties.MessageFormat = 'XML';

IF InputBody.TOT.MSG[1].LAST = 'WELCH' THEN
SET OutputLocalEnvironment.Variables.TOT.*[] = InputBody.TOT.*[];
DECLARE MSGNM REFERENCE TO OutputLocalEnvironment.Variables.TOT.*[];

END IF;

SET MSGNM.MSG[1].LAST = 'KAREN';
SET MSGNM.MSG[1].FIRST = 'WELCH';

It receives the following error at deploy time:

BIP2432E: (18, 5) : The correlation name 'MSGNM' is not valid. Those in scope are: Environment, InputLocalEnvironment, OutputLocalEnvironment, InputRoot, InputBody, InputProperties, OutputRoot, InputExceptionList, OutputExceptionList, InputDestinationList, OutputDestinationList, I.

The first element of a field reference must be a valid correlation name, from those in scope. This message may sometimes be due to an incorrectly formed or spelled expression which is not intended to be a field reference being parsed as if it were a field reference because the parser does not recognize it.

Correct the syntax of the expression and redeploy the message flow.

Thanks for your help.

Karen
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Mon Apr 15, 2002 8:12 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Spotted something immediately that causes me concern and can't see past this until we address it ... your statement

DECLARE MSGNM REFERENCE TO OutputLocalEnvironment.Variables.TOT.*[];

Says that you want to create a variable called MSGNM which points to the MULTIPLE ELEMENTS beneath TOT in the OutputLocalEnvironmentTree ....

The .*[] should be read as "ALL CHILDREN BENEATH". But since a reference variable can only have one value ... i.e. point to one and only one node in the tree, there is no semantic meaning to your statement. Suggest that you may want:

DECLARE MSGNM REFERENCE TO OutputLocalEnvironment.Variables.TOT.*[1];

But take care and understand what is meant.

See also http://www.kolban.com/mq/using_new_ESQL.htm
Back to top
View user's profile Send private message
kwelch
PostPosted: Mon Apr 15, 2002 8:20 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kolban,

I agree, that was a typo on my part when creating this example. This does not change the error on the deploy.

Karen


[ This Message was edited by: kwelch on 2002-04-15 09:22 ]
Back to top
View user's profile Send private message Send e-mail
kolban
PostPosted: Mon Apr 15, 2002 8:43 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Looking at the code ...

IF InputBody.TOT.MSG[1].LAST = 'WELCH' THEN
SET OutputLocalEnvironment.Variables.TOT.*[] = InputBody.TOT.*[];
DECLARE MSGNM REFERENCE TO OutputLocalEnvironment.Variables.TOT.*[];

END IF;

SET MSGNM.MSG[1].LAST = 'KAREN';
SET MSGNM.MSG[1].FIRST = 'WELCH';

If the "IF" statement evaluates to false then MSGNM will never be declared. If this is "possible", then the subsequent assignment statements will throw an error since "MSGNM" will be an unknown variable.... I kinda think it was smart of the deploy to catch this one
Back to top
View user's profile Send private message
kwelch
PostPosted: Mon Apr 15, 2002 8:55 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

Kolban,

Striving for simplicity is killing me!!!! We also had an IF THEN ELSE scenario so that either way something will get assigned and declared and it still gets the deploy error. I guess the bottom line is the DECLARE must be done outside of an IF THEN ELSE?

Thanks,

Karen
Back to top
View user's profile Send private message Send e-mail
kirani
PostPosted: Mon Apr 15, 2002 9:08 am    Post subject: Reply with quote

Jedi Knight

Joined: 05 Sep 2001
Posts: 3779
Location: Torrance, CA, USA

Karen,

I think it is a programming language feature. If you define a variable in a loop then its scope is restricted to that loop only. You cannot refer to it out of the loop. I think ESQL follows the same principles as any other programming language do.



_________________
Kiran


IBM Cert. Solution Designer & System Administrator - WBIMB V5
IBM Cert. Solutions Expert - WMQI
IBM Cert. Specialist - WMQI, MQSeries
IBM Cert. Developer - MQSeries

Back to top
View user's profile Send private message Visit poster's website
kwelch
PostPosted: Mon Apr 15, 2002 9:21 am    Post subject: Reply with quote

Master

Joined: 16 May 2001
Posts: 255

oh ok! I did not realize that about defining the variable in the loop. I guess it does make sense from that perspective then! Thanks for going round and round with me on this one!

Karen
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Using Declare ... Reference To ...
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.