IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

If the record not there it must be write in new file


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
reena_preethi

New User


Joined: 14 Jun 2006
Posts: 14

PostPosted: Sun Jun 18, 2006 2:59 pm
Reply with quote

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
View user's profile Send private message
khamarutheen

Active Member


Joined: 23 Aug 2005
Posts: 677
Location: NJ

PostPosted: Mon Jun 19, 2006 1:33 pm
Reply with quote

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
View user's profile Send private message
ralph_v

New User


Joined: 07 Jul 2005
Posts: 27

PostPosted: Mon Jun 19, 2006 8:24 pm
Reply with quote

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
View user's profile Send private message
reena_preethi

New User


Joined: 14 Jun 2006
Posts: 14

PostPosted: Tue Jun 20, 2006 6:16 pm
Reply with quote

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
View user's profile Send private message
philipraju
Warnings : 1

New User


Joined: 16 Apr 2006
Posts: 29

PostPosted: Wed Jun 21, 2006 1:03 am
Reply with quote

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
View user's profile Send private message
philipraju
Warnings : 1

New User


Joined: 16 Apr 2006
Posts: 29

PostPosted: Wed Jun 21, 2006 1:05 am
Reply with quote

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
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1448
Location: Chicago, IL

PostPosted: Wed Jun 21, 2006 3:59 am
Reply with quote

Reena,

You would have find this discussed, if made a search.
Back to top
View user's profile Send private message
reena_preethi

New User


Joined: 14 Jun 2006
Posts: 14

PostPosted: Wed Jun 21, 2006 10:46 am
Reply with quote

hello priyesh.agrawal thanks a lot. code helps me .

regards
reena
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon Jun 26, 2006 3:16 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 7
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top