Author |
Message
|
goffinf |
Posted: Thu Feb 21, 2008 11:45 am Post subject: Supported Java Return Type |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
I have a Java method that has an int return type. When I try to call it from eSQL I get an error which suggests that int is not supported. I can see in MB help that the eSQL INTEGER type corresponds to a Java Long, but I didn't see anything for int.
What eSQL type can I use for this ? Do I have to change the Java function to return a Long and match this on the eSQL side with INTEGER ??
Thanks
Fraser. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Feb 21, 2008 11:57 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You can return either a Long or an Integer, not an int.
I.e. you must return an object, not a primitive. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
goffinf |
Posted: Thu Feb 21, 2008 4:15 pm Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Thanks Jeff.
I tried using Long and that was fine. Couldn't get Integer to cooperate though. This was the error message :-
( WBRK6_DEFAULT_BROKER.default ) The Java method ''com.aviva.nui.cv.misctests.rcInteger.rcTest'' was found but its return type does not match the ESQL return type
This was the eSQL and Java :-
DECLARE ErrorID CHARACTER;
SET ErrorID = InputRoot.XMLNSC.CheckErrorIDInRange.ErrorID;
DECLARE retCode INTEGER;
-- Hmmm Integer version doesnt work - Long does though ?
SET retCode = rcIntegerTest(ErrorID);
CREATE FUNCTION rcIntegerTest(IN ErrorID CHARACTER)
RETURNS INTEGER LANGUAGE JAVA EXTERNAL NAME "com.aviva.nui.cv.misctests.rcInteger.rcTest";
public class rcInteger {
public static Integer rcTest(String arg1){
return new Integer(42);
}
} |
|
Back to top |
|
 |
mgk |
Posted: Fri Feb 22, 2008 1:54 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
If you read to docs you will see that ESQL integer maps to Java Long (object) as ESQL integers are 64bit (so may overflow a Java Integer(32bit)which is why this type is not used). Also ESQL datatypes can be null so cannot map to java primitives as they cannot be null.
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 |
|
 |
mgk |
Posted: Fri Feb 22, 2008 1:54 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
If you read to docs you will see that ESQL integer maps to Java Long (object) as ESQL integers are 64bit (so may overflow a Java Integer(32bit)which is why this type is not used). Also ESQL datatypes can be null so cannot map to java primitives as they cannot be null.
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 |
|
 |
goffinf |
Posted: Fri Feb 22, 2008 2:14 am Post subject: |
|
|
Chevalier
Joined: 05 Nov 2005 Posts: 401
|
Ahh I see, thanks, that makes it doublely clear
Fraser. |
|
Back to top |
|
 |
mgk |
Posted: Fri Feb 22, 2008 4:33 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Sorry for the double post reply, not sure what happened there! _________________ 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 |
|
 |
|