|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Why is my ESQL function return NULL ? |
« View previous topic :: View next topic » |
Author |
Message
|
KIT_INC |
Posted: Sun Jul 08, 2012 6:07 pm Post subject: Why is my ESQL function return NULL ? |
|
|
Knight
Joined: 25 Aug 2006 Posts: 589
|
I am using WMB V7 on Windows
In a compute node, I have
Begin
DECLARE MYMDC CHAR;
DECLARE MYINT, M1 INT;
SET MYMDC = 'MYDATA';
SET M1 = 3;
SET MYINT = 1;
/* call a function to process MYMDC and set the result to MYINT */
CALL MYFUNCTION(CYMDC, M1) INTO MYINT;
SET OutputRoot.XMLNS.MYMSG.DATA=MYINT;
:
END;
I have a ESQL file (MYFUNCTION.esql) in the same project
CREATE FUNCTION MYFUNCTION(IN MYMDC CHARACTER, OUT MM INTEGER) RETURNS INTEGER
BEGIN
DECLARE STR1 ,STR2, STRL , AA CHAR;
-- GET VALUE OF MYMDC
SET STR1 = MYMDC;
:
Do Some processing which changes STR1 into numbers
:
SET MM =CAST(STR1||STR2 AS INT);
END;
When I debug the flow, I can see the function beging called and MM contains the integer value I expect.
But MYINT did not get set with the value of MM instead it shows as blank in the debug screen.
I then run the user trace and see that MYINT was set to NULL.
UserTrace BIP2539I: Node 'TEST_CONVERT.Compute': Evaluating expression ''CAST(STR1 || STR2 AS INTEGER)'' at ('MYFUNCTION', '24.11'). This resolved to ''CAST('12345677' AS INTEGER)''. The result was ''12345677''.
2012-07-08 20:37:36.618080 5076 UserTrace BIP2537I: Node 'TEST_CONVERT.Compute': Executing statement ''SET OutputRoot.XMLNS.MYMSG.DATA =MYINT;'' at ('TEST_CONVERT_Compute.CopyEntireMessage', '9.3').
2012-07-08 20:37:36.618103 5076 UserTrace BIP2539I: Node 'TEST_CONVERT.Compute': Evaluating expression ''MYINT'' at ('TEST_CONVERT_Compute.CopyEntireMessage', '9.33'). This resolved to ''MYINT''. The result was ''NULL''.
This must be something very basic that I missed. Can some one help ? |
|
Back to top |
|
 |
rekarm01 |
Posted: Sun Jul 08, 2012 8:47 pm Post subject: Re: Why is my ESQL function return NULL ? |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Please use [code] tags when posting code; that makes it easier to read.
KIT_INC wrote: |
Code: |
CALL MYFUNCTION(CYMDC, M1) INTO MYINT;
...
CREATE FUNCTION MYFUNCTION(IN MYMDC CHARACTER, OUT MM INTEGER) RETURNS INTEGER
BEGIN
...
SET MM = CAST(STR1||STR2 AS INT);
END; |
|
If the function returns an INTEGER, it should have an explicit RETURN statement that provides an INTEGER expression.
KIT_INC wrote: |
But MYINT did not get set with the value of MM |
No. M1 gets set to MM instead, and MYINT gets set to NULL due to the missing RETURN statement. |
|
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
|
|
|
|