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 » Why is my ESQL function return NULL ?

Post new topic  Reply to topic
 Why is my ESQL function return NULL ? « View previous topic :: View next topic » 
Author Message
KIT_INC
PostPosted: Sun Jul 08, 2012 6:07 pm    Post subject: Why is my ESQL function return NULL ? Reply with quote

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
View user's profile Send private message
rekarm01
PostPosted: Sun Jul 08, 2012 8:47 pm    Post subject: Re: Why is my ESQL function return NULL ? Reply with quote

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
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 » Why is my ESQL function return NULL ?
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.