Author |
Message
|
KIT_INC |
Posted: Mon Dec 19, 2011 11:26 am Post subject: ESQL return type does not match |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
using WMB 61 on Windows or AIX. Try to create a function to get a timestamp in milliseconds
Create Function GetUnixTime() Returns INTEGER
Language Java External Name "java.lang.System.currentTimeMillis";
I call the function from within my ESQL code.
The code was deployed with no error.
But Keep getting error during execution "The Java method 'java.lang.System.currentTimeMillis' was found but its return type does not match the ESQL return type"
I know that java.lang.System.currentTimeMillis reurns long. According to info center
ESQL datatype INTEGER maps to java.lang.Long and that is what is used in the create function.
Any suggestion ? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Dec 19, 2011 11:30 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Have you tried mapping it to integer[]  _________________ MQ & Broker admin |
|
Back to top |
|
 |
KIT_INC |
Posted: Mon Dec 19, 2011 12:12 pm Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Sorry fjp_saper, not sure what you mean by "Have you tried mapping it to integer[] "
In the compute node that calls the function I have
tried
SET Environment.DATA.UTIME= GetUnixTime();
or Declare UTIME int;
set UTIME = GetUnixTime();
Just to be sure that it is not the calling ESQL causing the failure, I put the declare function and calling ESQLs within the same comute module and I commented out all the ESQL that calls the function. The failure is the same. So the problem is likely with the create function statement.
I don't know what to put in the the "Returns INTEGER " I did try with
"Returns decimal" (just try my luck) but same failure. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Dec 19, 2011 12:44 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Your Java function is not correct. It should read:
Code: |
return (int) (System.currentTimeMillis() / 1000L); |
_________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Dec 19, 2011 12:53 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Alternately, if you didn't want to divide by 1,000, you could use modulo to get the numeric down into an int. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Dec 19, 2011 1:47 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
I thought he said java returned a Long (autoboxed long) and he was mapping it to Integer in ESQL??  _________________ MQ & Broker admin |
|
Back to top |
|
 |
lancelotlinc |
Posted: Mon Dec 19, 2011 2:05 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
He did say that. I am suggesting he cast his Java return to an int and use modulo to get the proper value. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mgk |
Posted: Mon Dec 19, 2011 2:25 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Hi.
This error is because the ESQL INTEGER type maps to
which is the class (object) version of long and not the primitive long. The method you are trying to call returns the primitive so is not compatible. To call this method you will need to wrap it in a java method that returns the value as a
.
Kind 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 |
|
 |
KIT_INC |
Posted: Tue Dec 20, 2011 6:31 am Post subject: |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
Thanks for the suggestions. I am a java beginner. I'll try and feedback. |
|
Back to top |
|
 |
|