|   | 
	 
  
    | 
RSS Feed - WebSphere MQ Support
 | 
RSS Feed - Message Broker Support
 |   
 
  
	     | 
	 | 
   
 
  
	|  Access Global Environment Variables within a create function | 
	« View previous topic :: View next topic »  | 
   
  
  	
	  
		
		
		  | Author | 
		  Message
		 |  
		
		  | kamy | 
		  
		    
			  
				 Posted: Wed Apr 16, 2003 1:34 pm    Post subject: Access Global Environment Variables within a create function | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 26 Oct 2001 Posts: 21
  
  | 
		  
		    
			  
				Hi All,
 
We are creating a function using 'CREATE FUNCTION'.  Within the function, we would like to access our previously defined environment variable, which is structured as:
 
 
<Environment>
 
    <Field>Data</Field>
 
    <Field>Data</Field>
 
    <Field>Data</Field>
 
</Environment>.
 
 
Is there a way to pass this environment variable to the created function?
 
 
The function looks something like:
 
CREATE FUNCTION CHeckIsNull (FieldName CHAR, TotalCount INT) RETURNS Char 
 
BEGIN 
 
DECLARE NullIndex INT;
 
DECLARE IsNull CHAR;
 
SET NullIndex = 1;
 
SET IsNull = 'N';
 
WHILE IsNull = 'N' AND NullIndex <= TotalCount DO
 
	IF Environment.Field[NullIndex] = FieldName THEN
 
		SET IsNull = 'Y';
 
	END IF;
 
	SET NullIndex = NullIndex + 1;
 
 
END WHILE;
 
RETURN IsNull;
 
END;
 
 
This code is not deployable, indicating that 'Environment' is not a valid correlation name, but we have not been able to devise a way to pass the global environment variable to the function.
 
 
Any help would be greatly appreciated.  
 
 
Thank you very much.
 
K | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | warrenpage | 
		  
		    
			  
				 Posted: Wed Apr 16, 2003 4:18 pm    Post subject: Pass the Environment as a reference | 
				     | 
			   
			 
		   | 
		 
		
		   Acolyte
 
 Joined: 19 Feb 2002 Posts: 56 Location: Australia 
  | 
		  
		    
			  
				Use something like
 
 
 
CALL Audit(Environment,  'Audit Msg');
 
 
 
CREATE PROCEDURE Audit (IN Environment REFERENCE, IN remarks CHAR)
 
BEGIN
 
     DECLARE auditRoot REFERENCE to Environment.Audit;
 
 
     SET auditRoot.remarks = remarks;
 
  
 
END; | 
			   
			 
		   | 
		 
		
		  | Back to top | 
		  
		  	
		   | 
		 
		
		    | 
		 
		
		  | kamy | 
		  
		    
			  
				 Posted: Thu Apr 17, 2003 5:56 am    Post subject:  | 
				     | 
			   
			 
		   | 
		 
		
		   Novice
 
 Joined: 26 Oct 2001 Posts: 21
  
  | 
		  
		    
			  
				It Works, Thank You Very much. 
 
 
- k | 
			   
			 
		   | 
		 
		
		  | 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
  | 
  		 
	   
	 | 
   
 
  	 | 
	  |