View previous topic :: View next topic
|
Author |
Message |
priya_gmain
New User
Joined: 18 Sep 2006 Posts: 7
|
|
|
|
Hi,
Plz let me know how to delete a record in sequential file and rewrite the file in a cobol pgm. |
|
Back to top |
|
|
meetreks
New User
Joined: 28 Sep 2006 Posts: 26 Location: Edinburgh
|
|
|
|
Hi,
You cannot possibly delete a record in a sequential file. THe DELETE keyword is only of Indexed files,which can be deleted.
Hope this helps. |
|
Back to top |
|
|
priya_gmain
New User
Joined: 18 Sep 2006 Posts: 7
|
|
|
|
Ya I know that ......But in an interview I have been asked that if there is a requirement to delete a record in sequential file and rewrite .....how do u do that.......... |
|
Back to top |
|
|
nachiks
New User
Joined: 08 Apr 2006 Posts: 1 Location: chennai
|
|
|
|
HI,
We cannot delete records using DELETE in sequential files but we can logically delete the records.What we can do is we can rewite a record with SPACES. It looks like this
Code: |
BTECH124 A---
BTECH125 B---
BTECH127 C--- |
TRY THIS
Code: |
DECLARE A FILE
01 REC.
02 EMPNO PIC X(15).
02----
02----
IN WSS.
DECLARE A "77 EMPLOYEENO PIC A(15). "
ACCEPT EMPLOYEENO.
READ SEQUENTIAL-FILE <eof> /* NOW IT READS ALL RECORDS
IF EMPLOYEENO = EMPNO /*IF CONDITIONS PICKS A REC.
MOVE SPACES TO REC. /* SPACES ARE MOVED TO THAT REC
REWRITE REC. /* NOW REWITING WILL MAKE SPACES |
PLS CHEK
BYE |
|
Back to top |
|
|
|