0 pts.
 Embedded SQL in SQLRPGLE using JOIN on multiple files
Greetings, In the past I've used embedded SQL in an SQLRPGLE program and on the FETCH INTO statement I specify an externally defined data structure with the definition of the file I am SQLing thus allowing me to read in the entire record's fields mapped correctly in one FETCH INTO statement... This works great when you're SQLing one file... I'm currently joining 5 files together and I would like to capture the content of all 5 record's fields mapped correctly using one FETCH INTO statement...? Can I use this same trick when joining two or more files...? Can this be done or am I barking up the wrong tree...? Thanks.

Software/Hardware used:
ASKED: August 21, 2006  2:32 PM
UPDATED: May 28, 2008  8:26 PM

Answer Wiki:
I have done this before with JOIN on multiple files with no problems. Just make sure the data structure you fetch into is defined to match the fields on your SELECT. All fields will be defined in the same data structure. This makes it kind of hard to just define the data structure externally to match a particular file layout. Are you pulling in all fields from each file in the join? You could create a dummy file containing all fields from each file being joined in the order the SELECT pulls them in and then use this empty file just to define the data structure. The one problem you might run into when joining depends on if you are doing a straight join or a left join. With a left join you could get null values pulled in on secondary file fields and if you don't define the fields on your SELECT with an IFNULL or COALESCE to set the input data to zeros or blanks, this could cause a problem on the fetch. Sorry but this does not answeer the question of how to join more than 2 files
Last Wiki Answer Submitted:  May 28, 2008  8:26 pm  by  WaltZ400   645 pts.
All Answer Wiki Contributors:  WaltZ400   645 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _