Combining Records from Multiple Files/Multiple libraries (1 viewing) (1) Guest
Favoured: 0
|
|
|
TOPIC: Combining Records from Multiple Files/Multiple libraries
|
|
|
|
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.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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-->
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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-->
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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>
K CUSTOMER <BR>
K ITEM <BR>
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
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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.
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
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
|
|
|
|
|
|
|
The administrator has disabled public write access.
|
|
|
|
|