Have you been memorizing field names or relying on F4 prompting?
When creating file joins using interactive SQL (STRSQL), it's sometimes difficult to remember the field names that you want to join. I typically don't memorize field names and totally rely on the F4 prompting to get the names from the "SELECT fields" line.
Unfortunately, sometimes I can't use this method because I have not yet created a valid "FROM files" clause. So I'm stuck with the "CUSTOMER inner join SALES" on the "FROM files" line and no field names to complete the join clause. Creating a second session and performing a DSPFFD command would solve the problem, but here's a quicker, easier solution.
On the "FROM files" line, enter your file-level joins (CUSTOMER left join SALES). Then, enter an "absolute positive" field-level join criteria like ON 1=1.
FROM files . . . . . . . . . CUSTOMER inner join SALES
on 1=1
Since the files are now correctly joined, you can tab down to "SELECT fields" and press F4 to prompt the file field names. Select the fields using odd numbers on the first file fields and even numbers on the second file fields.
Seq Field File TEST
1 CUCNBR CUSTOMER Customer Number
3 CUCRGN CUSTOMER Customer Region
CUADD1 CUSTOMER Customer Address 1
CUADD2 CUSTOMER Customer Address 2
CUCITY CUSTOMER Customer City
2 SLCUNO SALES Customer Number
4 SLCURG SALES Customer Region
SLORNO SALES Order Number
SLORTY SALES Order Type
SLORDT SALES Order Date
Press Enter. Your selected fields will return in the order that matches.
CUSTOMER.CUCNBR, SALES.SLCUNO, CUSTOMER.CUCRGN,
SALES.SLCURG
Cut and paste the fields from the "SELECT fields" lines to the "FROM files" lines and format by replacing the comma with equal signs (=), and's, and or's.
FROM files . . . . . . . . . CUSTOMER inner join SALES
on CUSTOMER.F1FLD1 = SALES.F2FLD1 and
CUSTOMER.F1FLD2 = SALES.F2FLD2
SELECT fields . . . . . . . *
LATEST COMMENTS
MC Press Online