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

Interview question to write the records from A & B to C


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dipumain

New User


Joined: 05 Nov 2006
Posts: 1

PostPosted: Wed Nov 15, 2006 12:08 pm
Reply with quote

There are 2 tables A , B ..

There are 3 files C , D and E

now... the conditions to write the records from A & B to C,D,E files .. is...


if the Record found in A and B then write that record into C
if the Record found in A and not in B then write that record into D
if the Record found in B and not in A then write that record into E


.. Plzz place the code for this..

thanking you...
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Nov 15, 2006 2:29 pm
Reply with quote

this kind of thing can be accomplished by sort. there are probably 10 million variations of this question in the SORT forum. plzz look there!
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Wed Nov 15, 2006 2:59 pm
Reply with quote

Dipu,

The question is unclear, so I'm assuming few things:

Quote:
if the Record found in A and B then write that record into C

Code:
SELECT * FROM Table_A WHERE Pri_Id IN (SELECT Pri_Id FROM Table_B)

Quote:
if the Record found in A and not in B then write that record into D

Code:
SELECT * FROM Table_A WHERE Pri_Id NOT IN (SELECT Pri_Id FROM Table_B)

Quote:
if the Record found in B and not in A then write that record into E

Code:
SELECT * FROM Table_B WHERE Pri_Id NOT IN (SELECT Pri_Id FROM Table_A)


And write the records returned by the queries accordingly.

Cheers, Twissi.
Back to top
View user's profile Send private message
vijay_bn79

New User


Joined: 20 Nov 2006
Posts: 48
Location: Hyderabad

PostPosted: Mon Nov 20, 2006 3:03 pm
Reply with quote

Hi..,

the concept of JOIN i.e

INNER JOIN
OUTER JOIN

Will provide you the solution

Thanks icon_biggrin.gif
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
No new posts EZT program to build a flat file with... All Other Mainframe Topics 9
Search our Forums:

Back to Top