In summary, you need a good skeleton of a SQLRPGLE program that processes 
a subfile, backwards and forwards.
And the other question is:  Are you better off using multiple cursors (for 
the different selection criteria) or using "prepared" statements?  Dynamic 
sql or not?
There are better 5250 programmers out there so I'll hope you get a good 
template from them.
As far as the cursors go, study this:
Step 1:  Build a rpg variable that has all this in it.
MySqlStmt =
Declare C1 cursor for
Select t1.col11, t1.name, t1.col13, t2.zip, t3.city
from table1 t1
  join table2 t2
    on t1.col12 = t2.itskey
  join table3 t3
    on t1.col13 = t3.itskey
where t1.name between ? and ?
  and t2.zip between ? and ?
  and t3.city between ? and ?
order by ...
Comment:  The question marks are called "parameter markers".  More on this 
later...
Step 2:  Prepare a sql statement from this variable
exec sql Prepare Stmt1 from :MySqlStmt;
Step 3:  Declare the cursor from the prepared statement.
exec sql Execute Stmt1;
Step 4:  Open the cursor.  Pass in variables into the parameter markers. 
If you only want a single value for "t2.col2a" then pass the same variable 
into the left and the right of the and.
exec sql Open c1  using :FromName, :ToName, :FromZip, :ToZip, :FromCity, 
:ToCity;
Then you do your fetches and whatnot.
Study also:
- Soundex   
http://preview.tinyurl.com/sqlsoundex
- like   
http://preview.tinyurl.com/sqllike
Rob Berendt
 
As an Amazon Associate we earn from qualifying purchases.