MC Press Online Forum
Welcome, Guest
Please Login or Register.    Lost Password?
Combining Records from Multiple Files/Multiple libraries (1 viewing) (1) Guest
Go to bottom Post Reply Favoured: 0
TOPIC: Combining Records from Multiple Files/Multiple libraries
#73217
Guest.Visitor (Visitor)

Birthdate:
Combining Records from Multiple Files/Multiple libraries 11 Months, 3 Weeks ago  
Familiar w/SQL? Just STRSQL and run Selects w/UNION's to bring it all together...The SELECT's pull it all together for you. You just need to wrap this selection in a stmt like: <p>CREATE GLOBAL TEMPORARY TABLE table-name AS ( <BR>
SELECT A.* FROM ALIB/ORDRMST A <BR>
UNION ALL <BR>
SELECT B.* FROM BLIB/ORDRMST B <BR>
UNION ALL <BR>
SELECT C.* FROM CLIB/ORDRMST C) <BR>
WITH DATA WITH REPLACE <p>This will create a table in your Qtemp library containing all the records from all the ORDRMST's in the SELECT stmts...Hope this helps.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73218
Guest.Visitor (Visitor)

Birthdate:
Combining Records from Multiple Files/Multiple libraries 11 Months, 3 Weeks ago  
That's a DECLARE GLOBAL TEMPORARY TABLE... <p>DECLARE GLOBAL TEMPORARY TABLE table-name AS ( SELECT A.* FROM ALIB/ORDRMST A UNION ALL SELECT B.* FROM BLIB/ORDRMST B UNION ALL SELECT C.* FROM CLIB/ORDRMST C) WITH DATA WITH REPLACE
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73219
Guest.Visitor (Visitor)

Birthdate:
Combining Records from Multiple Files/Multiple libraries 11 Months, 3 Weeks ago  
And a little closer to what you want to do if I may be so assumptive. <BR>
You need to bring all the "facility" library data-files into a single or "global" duplicate of the files ie. ORDRMST, etc. for an "ownership's" visibility of his/her/their's vast domain...Let ma also assume you'll want this done after peek hours when you're normally asleep. <p>So you duplicate each file (one copy) into your "global" library, assuming they are all the same format. Let's say however that you create a table/file with a 1A field preceding the otherwise duplicated file/fields. Because, In this example let's say you need a way in the resulting file to see what "library" the record actually came from. (Say you don't have a way to tell in the data and there might be duplicate "order" numbers or something like that. <p>You will want to "schedule" a job to be submitted at your discretion that will simply run the RUNSQLSTM command. You will specify the SQL script member below with multiple SQL stmts separated by semicolons. <BR>
Hope this is more applicable. Good Luck <p><!--mccodelink_begin--> <BR>
<!-- do not remove --> <BR>
<hr width=50 align=left><small><a href='http://www.mcpressonline.com/mc/showcode@@.6b50a53f/2' target='_blank'>Code</a></small> <BR>
<!--mccodelink_end-->
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73220
austino@aol.com (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Combining Records from Multiple Files/Multiple libraries 11 Months, 2 Weeks ago Karma: 0  
If so, and your record formats are all the same, something like the following may suit your needs. <p><!--mccodelink_begin--> <BR>
<!-- do not remove --> <BR>
<hr width=50 align=left><small><a href='http://www.mcpressonline.com/mc/showcode@@.6b50a53f/3' target='_blank'>Code</a></small> <BR>
<!--mccodelink_end-->
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73221
Skalizar (User)
Fresh Boarder
Posts: 2
graphgraph
User Offline Click here to see the profile of this user
Combining Records from Multiple Files/Multiple libraries 11 Months, 1 Week ago Karma: 0  
It's been a long time since I've done this, but if I recall, this doesn't merge all the files, it just reads them in order. So you'll get all the records from the first file in keyed order, then all the records from the second file, etc. You can retrieve which file is being read from the file INFDS.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73222
austino@aol.com (User)
Fresh Boarder
Posts: 6
graphgraph
User Offline Click here to see the profile of this user
Combining Records from Multiple Files/Multiple libraries 11 Months, 1 Week ago Karma: 0  
"doesn't merge all the files, it just reads them in order" <p>The records will be processed as though they were coming from one combined file. The order they are processed depends entirely on how the keys are defined for the LF. <p>For example, if defined as: <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K CUSTOMER <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K ITEM <BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K ORDERDATE <p>Then reading this keyed-logical file will give you the records in the following sequence: <p>ORDERDATE within ITEM within CUSTOMER <p>Remember: The RPG compiler will not allow this type of file due to the fact that it has duplicate record formats. <BR>
When you compile a pgm with one, OVRDBF to a file that you use only for compiling, one that has the DDS using only one PFILE: <BR>
PFILE(LIBRARYA/ORDFILE) <p>The pgm will run fine, you just need to "fake out" the compiler. <p>A few other things to remember: <BR>
- Queries/SQL can be run against this file <BR>
- UPDDTA (DFU) cannot <BR>
- Select/Omit may be specified, if desired, in the DDS
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73223
Guest.Visitor (Visitor)

Birthdate:
Combining Records from Multiple Files/Multiple libraries 11 Months, 1 Week ago  
While you're deciding which one of the above mentioned ways will work best for you...Might as well throw this "approach" in there too. A well written trigger program attached to each of your "facility" library physicals could maintain the "global" or combined data-files where your global data would always be "current". <p>A little more effort up front but when you're done with it...You're done worrying about whether the "job" that does the populating got submitted, finished, blew-up, or whatever every night. Performance <BR>
wise, your choice may vary. With every comfort, there is a cost.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#73216
mahasuresh (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
Combining Records from Multiple Files/Multiple libraries 11 Months, 1 Week ago Karma: 0  
Hi All <p>I have a very unique question. <p>Our Data Base consists of Files which reside in multiple libraries. For example ORDRMST existing in several libraries. These libraries are unique for each facility. <p>We want to create a library that houses the combined records of these files from various libraries. <p>Is there any way of accomplishing this, without having to write programs that copy the records from these various libraries. <p>Please let me know. <p>Thanks for all your help <p>- Suresh
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
Powered by FireBoardget the latest posts directly to your desktop
   MC-STORE.COM