|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Passing reference variable as INOUT to the java procedure |
« View previous topic :: View next topic » |
Author |
Message
|
Mercury |
Posted: Mon Dec 11, 2006 5:59 am Post subject: Passing reference variable as INOUT to the java procedure |
|
|
 Apprentice
Joined: 24 Jun 2006 Posts: 32 Location: Hyderabad
|
Hi MBIANS,
I am trying to pass a reference variable to the Java procedure.My requirement is -- java function should modify the reference variable
Here is my code
CALL CopyMessageHeaders();
CREATE FIELD OutputRoot.XML.Data.Result;
SET OutputRoot.XML.Data.Result[] = LIST{InputRoot.XML.Car.colour,'green','BLUE','red','GREEN'};
DECLARE myVar CHAR 'dummy';
DECLARE myRef REFERENCE TO OutputRoot.XML.Data;
CALL testArray(myVar,myRef.Result[]);
---
Here is my fn call
CREATE FUNCTION testArray (IN var CHAR, INOUT myArray REFERENCE)
LANGUAGE JAVA
EXTERNAL NAME "com.xyz.MyUtil.test";
--------
Here is my java fn
public static void test(String var, MbElement[] actual){
--setting pointer
MbElement dum = actual[0];
try{
int i=1;
while (dum != null){
dum.setValue("abc" + i);
if (i>2)
dum.detach();
i++;
dum= dum.getNextSibling();
}
actual[0] = dum;
}catch (Exception e){
/*---------------*/
}
}
Expected o/p for this is SET OutputRoot.XML.Data.Result[] should have caridnality 2 with list members abc1 and abc2. But it contains abc1,abc2,red,GREEN
Can any one please find out where I am going wrong in java fn
thanks in advance  |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Dec 11, 2006 6:19 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Your Java procedure does many things that you don't want it to do.
In particular, you're looping until dum == null, and then assiging actual to dum.
You're also getting the next sibling of dum after you've detached it. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Mercury |
Posted: Mon Dec 11, 2006 6:30 am Post subject: |
|
|
 Apprentice
Joined: 24 Jun 2006 Posts: 32 Location: Hyderabad
|
thanks for the reply jefflowrey
my Idea was storing the modified list in the dum and copying again into actual.Since modifying the INOUT reference parameter directly doesn't give the modified list to the function. So I did like this
What do u suggest ? |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Dec 11, 2006 6:34 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'd suggest you write the procedure in ESQL until you get it working, and then convert the ESQL to java. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|