View previous topic :: View next topic
|
Author |
Message |
itsdipu Currently Banned New User
Joined: 18 Mar 2006 Posts: 3 Location: Hyderabad
|
|
|
|
Two tables EmpA and EmpB.
EmpA -- 100,000 Records,
EmpB -- 300,000 Records,
Question :
How to move the Records , which are existed in both , to EmpC table ?
How to move the records which are in EmpA and not in EmpB ?
How to move the records which are in EmpB and not in EmpA ?
Very thankful to you...
Thanks&Regards,
Dileep |
|
Back to top |
|
|
balakrishna reddy
Active User
Joined: 13 Jul 2007 Posts: 128 Location: Guntur
|
|
|
|
hi dileep,
the last two questions where seems to be incomplete
Quote: |
How to move the records which are in EmpA and not in EmpB ?
How to move the records which are in EmpB and not in EmpA ?
|
you didn't mentioned where to move the records if records of EMPA doesn't match EMPB and viceversa..
please provide the above information. |
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
Hello,
I would like to try to answer your question. I did it in COBOL.
FILE-A = FILE A
FILE-B = FILE B
FILE-C = FILE CONTAINING RECORDS IN BOTH A AND B
FILE-D = FILE CONTAINING RECORDS ONLY IN FILE A AND NOT IN B
FILE-E = FILE CONTAINING RECORDS ONLY IN FILE B AND NOT IN A
READ A
READ B
PERFORM UNTIL END-OF-FILE-A OR END-OF-FILE-B
EVALUATE TRUE
* RECS COMMON TO BOTH GET PUT TO FILE-C
WHEN REC-A = REC-B
WRITE REC-A TO FILE-C
READ A
READ B
WHEN REC-A < REC-B
* RECS ONLY IN FILE-A GET WRITTEN TO FILE-D
WRITE REC-A TO FILE-D
READ A
WHEN REC-A > REC-B
* RECS ONLY IN FILE B GET WRITTEN TO FILE-E
WRITE REC-B TO FILE-E
READ B
END-EVALUATE
END-PERFORM
* IF B IS EMPTY FROM LOOP ABOVE AND A IS NOT
PERFORM UNTIL END-OF-FILE-A
READ A
WRITE REC-A TO FILE-D
END-PERFORM
* IF A IS EMPTY FROM FIRST LOOP AND B IS NOT
PERFORM UNTIL END-OF-FILE-B
READ B
WRITE REC-B TO FILE-E
END-PERFORM
Regards. |
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
I forgot to say to please sort both input files before using the code above.
Regards. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello itsdipu and welcome to the forums,
To to what you want you will implement something known as a 2-file match/merge.
There is a "sticky" at the top of "Mainframe COBOL " that is sample code for your requirement.
Please download the code, review it, and post any questions you have as a reply here. |
|
Back to top |
|
|
itsdipu Currently Banned New User
Joined: 18 Mar 2006 Posts: 3 Location: Hyderabad
|
|
|
|
Hi Bacay,
Yes , the scenario what u mentioned here is exactly my scenario. thanks for understanding correctly.. I really feeling good to see this code. One more question on this..
Say, its taking one unit of time to check for one condition.
How many times it has to perform the same condition check. and hence is it not decreasing the performance of mainframe computer. ??
plz let me know. if my question is not clear.
Thanks
Dileep
Raphael Bacay wrote: |
Hello,
I would like to try to answer your question. I did it in COBOL.
FILE-A = FILE A
FILE-B = FILE B
FILE-C = FILE CONTAINING RECORDS IN BOTH A AND B
FILE-D = FILE CONTAINING RECORDS ONLY IN FILE A AND NOT IN B
FILE-E = FILE CONTAINING RECORDS ONLY IN FILE B AND NOT IN A
READ A
READ B
PERFORM UNTIL END-OF-FILE-A OR END-OF-FILE-B
EVALUATE TRUE
* RECS COMMON TO BOTH GET PUT TO FILE-C
WHEN REC-A = REC-B
WRITE REC-A TO FILE-C
READ A
READ B
WHEN REC-A < REC-B
* RECS ONLY IN FILE-A GET WRITTEN TO FILE-D
WRITE REC-A TO FILE-D
READ A
WHEN REC-A > REC-B
* RECS ONLY IN FILE B GET WRITTEN TO FILE-E
WRITE REC-B TO FILE-E
READ B
END-EVALUATE
END-PERFORM
* IF B IS EMPTY FROM LOOP ABOVE AND A IS NOT
PERFORM UNTIL END-OF-FILE-A
READ A
WRITE REC-A TO FILE-D
END-PERFORM
* IF A IS EMPTY FROM FIRST LOOP AND B IS NOT
PERFORM UNTIL END-OF-FILE-B
READ B
WRITE REC-B TO FILE-E
END-PERFORM
Regards. |
|
|
Back to top |
|
|
Raphael Bacay
New User
Joined: 04 May 2007 Posts: 58 Location: Manila, Philippines
|
|
|
|
Hello,
Yes it is taking one unit at a time. I don't think it will hurt
mainframe processing much because it is only fair to do it
this way since this is in COBOL and COBOL usually processes one recored at a time. Also the forum is COBOL oriented anyway.
Regards. |
|
Back to top |
|
|
|