| Author | 
		  Message
		 | 
		
		  | vickykarumbhu | 
		  
		    
			  
				 Posted: Mon Jun 08, 2015 11:52 pm    Post subject: Array in Database | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 08 Jun 2015 Posts: 6
  
  | 
		  
		    
			  
				Hi All,
 
I have fetched two fields from DB using passthrough function and stored it in environment variables.  I need to declare a reference to point tat environment variables.  But if in specify like this I am getting only the first instance DECLARE newref REFERENCE TO Environment.Variables.ODList[ODList];.  Please help me on this   | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Tue Jun 09, 2015 1:04 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				Can a moderator please move this post to the Broker forum
 
 
To the OP, can you please show us a bit more of the code in order to help set the context a bit better. Please include the PASSTHRU line as well. _________________ 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vickykarumbhu | 
		  
		    
			  
				 Posted: Tue Jun 09, 2015 1:19 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 08 Jun 2015 Posts: 6
  
  | 
		  
		    
			  
				SET Environment.Variables.ODList[ODListcount] = PASSTHRU('SELECT s.filed1,s.field2 FROM dev1.table AS s');
 
	Both the field1 and 2 values are present under ODLIST as 
 
	WMQI_Environment
 
	Variables
 
		ODList
 
			AIRPORT_CODE:CHARACTER:AAL
 
			COUNTRY:CHARACTER:DK 
 
		ODList
 
			AIRPORT_CODE:CHARACTER:AAR
 
			COUNTRY:CHARACTER:DK
 
			and so on...
 
	DECLARE newref REFERENCE TO Environment.Variables.ODList[ODList];//This reference points only to the first value of odlist
 
	WHILE LASTMOVE (newref)  DO
 
	IF (DepRef = Environment.Variables.ODList[ODList].AIRPORT_CODE) THEN
 
		SET DomesticFlag = 1;
 
	END IF;
 
	MOVE newref NEXTSIBLING REPEAT TYPE NAME; 
 
	END WHILE; | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | smdavies99 | 
		  
		    
			  
				 Posted: Tue Jun 09, 2015 2:03 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land. 
  | 
		  
		    
			  
				
   
	| Code: | 
   
  
	
 
SET Environment.Variables.ODList[ODListcount] = PASSTHRU('SELECT s.filed1,s.field2 FROM dev1.table AS s');
 
Both the field1 and 2 values are present under ODLIST as
 
WMQI_Environment
 
Variables
 
ODList
 
AIRPORT_CODE:CHARACTER:AAL
 
COUNTRY:CHARACTER:DK
 
ODList
 
AIRPORT_CODE:CHARACTER:AAR
 
COUNTRY:CHARACTER:DK
 
and so on...
 
DECLARE newref REFERENCE TO Environment.Variables.ODList[ODList];//This reference points only to the first value of odlist
 
WHILE LASTMOVE (newref) DO
 
IF (DepRef = Environment.Variables.ODList[ODList].AIRPORT_CODE) THEN
 
SET DomesticFlag = 1;
 
END IF;
 
MOVE newref NEXTSIBLING REPEAT TYPE NAME;
 
END WHILE;
 
 | 
   
 
 
 
Your post is much easier to read when wrapped in [C O D E] tags.
 
 
The PASSTHRU statement would normally be written as something like
 
   
	| Code: | 
   
  
	
 
SET Environment.Variables.ODList[] = PASSTHRU('SELECT s.filed1,s.field2 FROM dev1.table AS s'); 
 
 | 
   
 
 
 
Then this
 
   
	| Code: | 
   
  
	
 
IF (DepRef = Environment.Variables.ODList[ODList].AIRPORT_CODE) THEN 
 
 | 
   
 
 
 
might only ever refer to the first element in the list. Should you not be using 'newref' here? _________________ 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 | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | vickykarumbhu | 
		  
		    
			  
				 Posted: Tue Jun 09, 2015 5:25 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Newbie
 
 Joined: 08 Jun 2015 Posts: 6
  
  | 
		  
		    
			  
				| Yes. I need to traverse to all the elements listed in environment and should check the values.  So how could i store all the field1 values into one array from the environment variables.  guide me on this | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Tue Jun 09, 2015 5:32 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| vickykarumbhu wrote: | 
   
  
	| So how could i store all the field1 values into one array from the environment variables. | 
   
 
 
 
   
	| smdavies99 wrote: | 
   
  
	
   
	| Code: | 
   
  
	|  SET Environment.Variables.ODList[] = PASSTHRU('SELECT s.filed1,s.field2 FROM dev1.table AS s');  | 
   
 
 | 
   
 
 
 
 
   
	| vickykarumbhu wrote: | 
   
  
	|  guide me on this | 
   
 
 
 
He did. _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |