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 » Array in ESQL

Post new topic  Reply to topic
 Array in ESQL « View previous topic :: View next topic » 
Author Message
Sridar
PostPosted: Thu May 18, 2006 3:32 am    Post subject: Array in ESQL Reply with quote

Acolyte

Joined: 14 May 2006
Posts: 72
Location: Chennai, India

Hi

I am trying to reduce the 4 Procedure calls to 1 by trying to send all the variables in a single call and then get each variable one by one in the Procedure and executing it(procedure).

Since there is no Array datatype(WBI V5.0) i am trying to set these values to Environment variables using a LIST and pass the Environmnet Variables to the Procedure.

Can anyone help me in how to do this exactly or is there any other way of doing this.

Here is the piece of code i have done.
****
In the Main flow

DECLARE Mandatory CHARACTER;

CREATE FIELD Environment.Variables.Mandatory[];

DECLARE MANDATORY REFERENCE TO Environment.Variables.Mandatory;

SET Environment.Variables.Mandatory[] = LIST{a,b,c,d};

CALL com.tgt.esb.imn.common.Check_Mandatory_Fields
(Environment.Variables.Mandatory);

*****
*****
In common flow where Procedure resides

CREATE PROCEDURE Check_Mandatory_Fields(IN MANDATORY CHARACTER)
BEGIN

DECLARE FIELD_NAME CHARACTER '';
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(MANDATORY.*[]);

WHILE I <= J DO
SET FIELD_NAME = MANDATORY[I];

--- STATEMENTS TO BE EXECUTED---

ELSE
SET I = I + 1;

END IF;

**************
I am getting Error in this statement:
SET FIELD_NAME = FIELD[I];

Can anyone Help? Sorry for such a long mail.

Thanks
Sridar[/list]
_________________
Thanks and Regards
Sridar
Back to top
View user's profile Send private message
elvis_gn
PostPosted: Thu May 18, 2006 3:57 am    Post subject: Reply with quote

Padawan

Joined: 08 Oct 2004
Posts: 1905
Location: Dubai

Hi Sridar,

Code:
CALL com.tgt.esb.imn.common.Check_Mandatory_Fields
(Environment.Variables.Mandatory);

Sending a list

Code:
CREATE PROCEDURE Check_Mandatory_Fields(IN MANDATORY CHARACTER)

Defining in a Character...i.e storing in a character

Code:
SET FIELD_NAME = MANDATORY[I];

Trying to use a list when u defined it as a character....

Rest you should figure out....are u not using the debugger....you sould have been able to check this there.

Regards.[/code]
Back to top
View user's profile Send private message Send e-mail
mgk
PostPosted: Thu May 18, 2006 4:01 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

Hi,

What is the error, you don't say?

Also, your code is wrong in places. Is this the actual code you are using, or did you just retype it here? If you retypes it, then please post the actual code (or as near as you can), as it makes understanding your problem much harder.

For example, you declare a reference called MANDATORY then do not use it in the code you posted. I assume you ment to pass it as the parameter to your procedure?

e.g. CALL com.tgt.esb.imn.common.Check_Mandatory_Fields
(MANDATORY);

If so, then your procedure prototype is wrong. It should be:

CREATE PROCEDURE Check_Mandatory_Fields(IN MANDATORY REFERENCE)


Also you say
Quote:
am getting Error in this statement: SET FIELD_NAME = FIELD[I];


But this statement does not appear in the code you posted. Again, please make sure your code makes sense in terms of the question you are asking. I assume you mean when MANDATORY when you ment FIELD in this case, and if so then as I showed above, MANDATORY needs to be a REFERENCE parameter to the procedure.

Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Sridar
PostPosted: Thu May 18, 2006 4:45 am    Post subject: Reply with quote

Acolyte

Joined: 14 May 2006
Posts: 72
Location: Chennai, India

Hi elvis and mgk

Thanks for your response.

elvis:Trying to use a list when u defined it as a character....

I am not clear on which variable you are referring to and how?

mgk: I have given the actual code here. I am getting Syntax error in the below statement

SET FIELD_NAME = MANDATORY[I];

Actually i tried to pass a reference to the procedure but was in doubt whether it would work so i tried passing the actual values.

I do not mind how i pass it, but i need to retrieve the variables one by one in the procedure.

As you had mentioned that the code is wrong in some places are there any other faults(like syntax errors) or only those that you had mentioned.

Any way can you please help me. Is there any other way of doing this.

*******
Main Flow

DECLARE Mandatory CHARACTER;

CREATE FIELD Environment.Variables.Mandatory[];

--DECLARE MANDATORY REFERENCE TO Environment.Variables.Mandatory;

SET Environment.Variables.Mandatory[] = LIST{a,b,c,d};

CALL com.tgt.esb.imn.common.Check_Mandatory_Fields
(Environment.Variables.Mandatory);
********
******
Procedure

CREATE PROCEDURE Check_Mandatory_Fields(IN MANDATORY CHARACTER)
BEGIN

DECLARE FIELD_NAME CHARACTER '';
DECLARE I INTEGER 1;
DECLARE J INTEGER CARDINALITY(MANDATORY.*[]);

WHILE I <= J DO
SET FIELD_NAME = MANDATORY[I];

--- STATEMENTS TO BE EXECUTED---

ELSE
SET I = I + 1;

END IF;

Thanks in Advance
Sridar
_________________
Thanks and Regards
Sridar
Back to top
View user's profile Send private message
mgk
PostPosted: Thu May 18, 2006 5:07 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

To make this work, you MUST pass a reference to the procedure like I suggested above. You are getting an error because you are dereferencing a CHARACTER string. You can only do this to a Field Reference or a Reference Variable. You should look up Field References in the docs, and look up how the message tree works.

Regards,
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Sridar
PostPosted: Thu May 18, 2006 5:43 am    Post subject: Reply with quote

Acolyte

Joined: 14 May 2006
Posts: 72
Location: Chennai, India

Thanks mgk

I created a reference and passed it to the procedure,
but i still have problem in the value assigning statement.
I am getting Syntax Error.

SET FIELD_NAME = MANDATORY[I]; where MANDATORY is the Reference to Environment.Variables.Mandatory where i have stored all the values and I is the increment variable.

I have declared FIELD_NAME as character

Is my Syntax correct or...

Thanks in Advance
Sridar
_________________
Thanks and Regards
Sridar
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Thu May 18, 2006 5:53 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

MANDATORY[I] will the be the I'th sibling named MANDATORY.

You want the I'th child of MANDATORY. So use MANDATORY.[I] instead.

But change the name of this to something other than MANDANTORY.

It's a horrible name for a variable.
_________________
I am *not* the model of the modern major general.


Last edited by jefflowrey on Thu May 18, 2006 6:22 am; edited 1 time in total
Back to top
View user's profile Send private message
mgk
PostPosted: Thu May 18, 2006 6:18 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1642

And another thing, once you have renamed mandatory to something nice as jeff suggests, you could try posting the ACTUAL error message when you get an error. Just posting

Quote:
I am getting Syntax Error.


Does not help as there are lots of possible syntax errors.

Also you said:

Quote:
Is my Syntax correct or...


As you got also say you got a syntax error, then the answer is clearly no, your syntax is not correct.
_________________
MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions.
Back to top
View user's profile Send private message
Sridar
PostPosted: Fri May 19, 2006 3:21 am    Post subject: Reply with quote

Acolyte

Joined: 14 May 2006
Posts: 72
Location: Chennai, India

Hi

Thanks for all your help.
I was actually trying to do a null check for mandatory fields and that's the reason for the name of the variable.
Neways have changed it.
jefflowrey: After following your idea there was no error. The exact error i got was 'Syntax Error' only.

But still i had problem in assigning the value as Null value was getting assigned eventhough the value of the node is not null.

Later i changed my logic slightly.
I used FIELDVALUE function to get the value and everything is now working fine.
Below is the code i did.

CREATE PROCEDURE Check_Mandatory(IN FIELD_REF REFERENCE)
BEGIN
WHILE LASTMOVE(FIELD_REF)=TRUE
DO
IF FIELDVALUE(FIELD_REF) IS NULL THEN
THROW EXCEPTION MESSAGE 3010 VALUES ('MANDATORY FIELD MISSING IN THE BUSEVENT MESSAGE:',FIELD_REF);
END IF;
MOVE FIELD_REF NEXTSIBLING;
END WHILE;
END;[/code]
_________________
Thanks and Regards
Sridar
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 » Array in ESQL
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.