| Author | 
		  Message
		 | 
		
		  | Prashanth007 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 1:37 am    Post subject: Query on esql | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 13 Oct 2015 Posts: 6
  
  | 
		  
		    
			  
				Hi all,
 
 
 
           I have a query regarding an esql. i wrote this code in my compute node:
 
CREATE COMPUTE MODULE Task_flow_Compute
 
                CREATE FUNCTION Main() RETURNS BOOLEAN
 
 
 
                BEGIN
 
                                CALL CopyMessageHeaders();
 
                    CALL CopyEntireMessage();
 
 
 
                                RETURN TRUE;
 
 
 
                               
 
                END;
 
--
 
                CREATE PROCEDURE CopyMessageHeaders() BEGIN
 
                                DECLARE I INTEGER 1;
 
                                DECLARE J INTEGER;
 
                                SET J = CARDINALITY(InputRoot.*[]);
 
                                WHILE I < J DO
 
                                                SET OutputRoot.*[I] = InputRoot.*[I];
 
                                                SET I = I + 1;
 
                                END WHILE;
 
                END;
 
 
 
                CREATE PROCEDURE CopyEntireMessage() BEGIN
 
 
 
if condition then
 
if condition then
 
   Statements;
 
else
 
   return false;
 
end if;
 
elseif condition then
 
    statements;
 
end if;
 
 
 
 
 
                END;
 
END MODULE;
 
 
 
 
 
       this is my code,when deploying my flow with this code
 
it is not deploying due to syntax error at return false.So i came to know that
 
return false will not work under procedure.my requirement is the message has to
 
discard/stop with in the compute node in procedure itself.
 
CAn you please help me in this query?
 
 
 
thank you. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | nelson | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 7:19 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Partisan
 
 Joined: 02 Oct 2012 Posts: 313
  
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 8:23 am    Post subject: Re: Query on esql | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				
   
	| Prashanth007 wrote: | 
   
  
	
 
   
	| Code: | 
   
  
	
 
                CREATE PROCEDURE CopyEntireMessage() BEGIN
 
 
 
if condition then
 
if condition then
 
   Statements;
 
else
 
   return false;
 
end if;
 
elseif condition then
 
    statements;
 
end if;
 
 
 
 
 
                END;
 
END MODULE;
 
 | 
   
 
 
 | 
   
 
 
 
You can't use the RETURN statement in an ESQL PROCEDURE.
 
It is only valid in a FUNCTION _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mgk | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 10:56 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 31 Jul 2003 Posts: 1647
  
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| You can't use the RETURN statement in an ESQL PROCEDURE. It is only valid in a FUNCTION | 
   
 
 
 
Almost  . PROCEDUREs can have a RETURNS clause as can FUNCTIONs and the RETURN statement must match the signature of the routine in which it is used. From the docs: 
 
 
   
	| Quote: | 
   
  
	| "When used in a function or a procedure, the RETURN statement stops processing of that function and returns control to the calling expression. The expression, which must be present if the function or procedure has been declared with a RETURNS clause, is evaluated and acts as the return value of the function. The data type of the returned value must be the same as that in the function's declaration" | 
   
 
 
 
http://www-01.ibm.com/support/knowledgecenter/SSMKHH_10.0.0/com.ibm.etools.mft.doc/ak05130_.htm?lang=en.
 
 
So in this case, using RETURN is fine, but it should not have an expression to RETURN, so remove the "false".
 
 
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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Prashanth007 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 7:39 pm    Post subject: query | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 13 Oct 2015 Posts: 6
  
  | 
		  
		    
			  
				thanks all,
 
 
     I have already executed this code in main() function but I want to execute the same code in procedure. But I don't know how to discard/stop my message with in procedure(like return false; in main()). So can you please suggest me how?
 
 
      
 
 
Thanks in advance. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | nelson | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 8:54 pm    Post subject: Re: query | 
				     | 
			   
			 
		   | 
		
		
		    Partisan
 
 Joined: 02 Oct 2012 Posts: 313
  
  | 
		  
		    
			  
				
   
	| Prashanth007 wrote: | 
   
  
	thanks all,
 
 
     I have already executed this code in main() function but I want to execute the same code in procedure. But I don't know how to discard/stop my message with in procedure(like return false; in main()). So can you please suggest me how?
 
 
      
 
 
Thanks in advance. | 
   
 
 
 
   
	| mgk wrote: | 
   
  
	| So in this case, using RETURN is fine, but it should not have an expression to RETURN, so remove the "false". | 
   
 
 | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Prashanth007 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 9:18 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 13 Oct 2015 Posts: 6
  
  | 
		  
		    
			  
				Thank you,
 
   Return is working when removal of false in my statement.but the count of output queue is increasing.my requirement is I have to terminate the message in compute node itself in else condition.And the message should not go to output queue.
 
 
 
 thanks in advance | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 9:36 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				Change your procedure to a FUNCTION (returns BOOLEAN) and do a 
 
 
RETURN TRUE
 
 
or
 
 
RETURN FALSE
 
 
at every exit point. 
 
Then call is using something like
 
 
   
	| Code: | 
   
  
	
 
 
 
  return MY_FUNCTION();
 
 | 
   
 
 
This calls your function and then exits the calling ESQL code with the value used in the return statement on the Function.
 
 
 
Problem solved! _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | stoney | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 9:37 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Centurion
 
 Joined: 03 Apr 2013 Posts: 140
  
  | 
		  
		    
			  
				| Change the procedure into a function that returns a boolean value indicating whether or not the message should be propagated, and then use that return value in the main() function? | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Prashanth007 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 10:05 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 13 Oct 2015 Posts: 6
  
  | 
		  
		    
			  
				Thank you all,
 
  But my requirement is I should do this in procedure itself.
 
I have to terminate the message in procedure.
 
And one more question that is Ho will i convert procedure into function?
  Last edited by Prashanth007 on Sun Oct 18, 2015 10:41 pm; edited 1 time in total | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Sun Oct 18, 2015 10:41 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				
   
	| Prashanth007 wrote: | 
   
  
	Thank you all,
 
  But my requirement is I should do this in procedure itself.
 
I have to terminate the message in procedure. | 
   
 
 
 
Why?
 
Why would a requirement be written as to force you into things that are not best practice (or even possible). The only way I know to terminate the message process int a procedure or function is to use a THROW statement but that will cause other things to happen that might bery well not meet your requirement.
 
 
You really need to go back to whoever wrote the requirement and tell them that what they want is not possible and that they must let you terminate processing in a way that is considered best practice with this product. And is also much more maintainable ....
 
 
 
Sometimes I get the impression that a lot of requirements are written by so called experts who have little of no experience with this product.
 
Please read this thread
 
www.mqseries.net/phpBB2/viewtopic.php?t=63535 _________________ WMQ User since 1999
 
MQSI/WBI/WMB/'Thingy' User since 2002
 
Linux user since 1995
 
 
 
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mqjeff | 
		  
		    
			  
				 Posted: Mon Oct 19, 2015 1:44 pm    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 17447
  
  | 
		  
		    
			  
				So what you want to do is, at some point in your code (inside a procedure or any other random location) cause a message to be sent out of a terminal.
 
 
And in the main function, you want to make sure it doesn't send out a message to any terminal.
 
 
This is eminently doable, if you use the correct ESQL statements to do both of those tasks.
 
 
Also, you should reexamine how you are starting your main routine, and what effect that is having on the output message. _________________ chmod  -R ugo-wx / | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |