Published on System iNetwork (http://systeminetwork.com)
Joining All Records in Query/400
By tzura
Created Aug 29 2002 - 04:00

In last week's issue, I discussed a technique for passing parameters to a Query/400 query using a file containing parameter values. The example queried an employee master file by location and department. The example joined every record in the employee master file to the file containing the parameter values. To join all records, the query performed a non-equal join on a dummy field. Last week's tip was based on more complex criteria than the example, and I want to clarify a point.

For last week's particular requirement of joining the parameter record to all records in the employee master file, you don't need to use the dummy field at all. Instead, you can enter the required information on the Specify File Selections panel and Specify Type of Join panel just the same as was done last week (as shown below). Then, on the Specify How to Join Files panel, enter *All for Field (also shown below).

                            Specify File Selections                  
 Type choices, press Enter.  Press F9 to specify an additional       
   file selection.                                                   
   File . . . . . . . . .   EMPLOYEES      Name, F4 for list         
     Library  . . . . . .     YOURLIB      Name, *LIBL, F4 for list  
   Member . . . . . . . .   *FIRST         Name, *FIRST, F4 for list 
   Format . . . . . . . .   EMPLOYEESR     Name, *FIRST, F4 for list 
   File ID  . . . . . . .   T01            A-Z99, *ID                
   File . . . . . . . . .   EMPPARMS       Name, F4 for list         
     Library  . . . . . .     YOURLIB      Name, *LIBL, F4 for list  
   Member . . . . . . . .   *FIRST         Name, *FIRST, F4 for list 
   Format . . . . . . . .   EMPPARMSR      Name, *FIRST, F4 for list 
   File ID  . . . . . . .   T02            A-Z99, *ID                

 
                              Specify Type of Join                            
 Type choice, press Enter.                                                    
   Type of join . . . . . . . .   1      1=Matched records                    
                                         2=Matched records with primary file  
                                         3=Unmatched records with primary file

 
                           Specify How to Join Files                    
 Type comparisons to show how file selections are related, press Enter. 
   Tests:  EQ, NE, LE, GE, LT, GT                                       
 Field             Test     Field                                       
 *ALL 

If you're adding a parameter file to a query that already joins files, you need do nothing special (dummy join field or *ALL not necessary) to join all records in the parameter file. Simply define the joins you would normally define for your files and the fields in the parameter file will be added to the records your join create.

Copyright © Penton Media

Source URL: http://systeminetwork.com/node/60719