View previous topic :: View next topic
|
Author |
Message |
reena_preethi
New User
Joined: 14 Jun 2006 Posts: 14
|
|
|
|
hi folks,
i got a question in one interview.
like they asked me to write a program to compare 2 files.if the record not there it must be write in new file.can any body give the coding .
thanks in advance.
reena |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
Reena,
Can you please explain in detail. If two files are compared whether you meant that file1 doesnot contain any data or file2 doesnot contain any data? and you are meaning JCL code to compare the file or COBOL code. Can you please make clear of this such that let us try for the next coding step. |
|
Back to top |
|
|
ralph_v
New User
Joined: 07 Jul 2005 Posts: 27
|
|
|
|
If I am correct the requirement was to compare 2 files , FILEA and FILEB and the if the match is found take corrective action.
The asnwer is Read FILEA and then start reading FILEB and if match is found or match not found code the necessary logic.
But you need to ensure that both the files are sorted.
Hope this helps |
|
Back to top |
|
|
reena_preethi
New User
Joined: 14 Jun 2006 Posts: 14
|
|
|
|
hi khamarutheen
the question is i writing some records in one file called a.i compare with the existing file called b.consider file a contains names like reena ,preethi,chinku like that.in file b it contains only reena and preethi only. i want to copy the remind record 'chinku' to file c.write a coding for that now the question is ok.
thanks
regards
reena |
|
Back to top |
|
|
philipraju Warnings : 1 New User
Joined: 16 Apr 2006 Posts: 29
|
|
|
|
select * from dept where not exists(select * from emp where dept.empno=emp.empno);
this query gives the result of the non existed values in emp table compared by the dept table. |
|
Back to top |
|
|
philipraju Warnings : 1 New User
Joined: 16 Apr 2006 Posts: 29
|
|
|
|
i think this is not right answer ....bcz of im just retriving the non existed records only....but u want to write those non existed records in to new...i dont know...pls if u know let me know |
|
Back to top |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
Back to top |
|
|
reena_preethi
New User
Joined: 14 Jun 2006 Posts: 14
|
|
|
|
hello priyesh.agrawal thanks a lot. code helps me .
regards
reena |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Priyesh is right. Look at that link. The solution to your problem is called the "file match algorithm".
It is one of the two most used algorithms in batch processing. The other is called the control break algorithm". They account for over 90% of the batch pgms in existence.
The most important thing you can do for yourself as a pgmr is learn and fully understand these 2 solutions. |
|
Back to top |
|
|
|