Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DELETE Sequential File

Status
Not open for further replies.

SiouxCityElvis

Programmer
Jun 6, 2003
228
US
Why would I get a clean compile to with code as the following shows, but yet the file does NOT get deleted?

OPEN INPUT TEST-FILE

blah blah blah code code code

CLOSE TEST-FILE

DELETE FILE TEST-FILE

I'm using RMCOBOL - 85 Version 8 on Linux. I get no runtime nor compile time errors.

I'm displaying the file path and file name and it is accurate.

Page 356 of the language ref manual states the following conditions must be met in order for a successful file deletion to occur:


• The file is not in the open mode.
• The file was not previously closed with lock during this execution of the program.
• The file exists.
• The runtime file system supports file deletion.
• The file is not protected from deletion by a mechanism of the runtime file system.
• The fixed file attributes specified for the file match the actual fixed file attributes of
the existing file.

I figure if one of the above is not met, it would be evident during execution or compile of the program, but maybe I'm misunderstanding something here. I'm running the program logged in as root on linux.

Thanks.
-David
 
No, I was in root, but I found what the problem was.

I did a
Code:
SELECT OPTIONAL FILE-RECORD ASSIGN TO INPUT, FILE-NAME ORGANIZATION IS LINE SEQUENTIAL

FD FILE-RECORD.
01 FILE-REC.
   03 FILE-NAME     PIC X(500).
01 FILE-RECB.
   03 FILE-FIELD    PIC X(4).
   03 FILE-FILLER   PIC X(496).

I was getting the FILE-NAME value later in my code and being able to open the FILE-RECORD based off that value.

Afterwards, I was populating(writing over the file-field value) the FILE-RECB with a different value. So, after I closed my file and attempted to DELETE it thinking it still held the original FILE-NAME value, I had the problem.
I corrected this by simply using a WS-FILE-NAME instead of a FILE-NAME, thus eliminating the 01 FILE-REC and now only needing the FILE-RECB definition of the file.

It was a foolish mistake, but I now know that in my SELECT statement, the file specified can be a working storage variable.

Thanks.
-David
 
Did you check the file status after the DELETE? If so, what was it?

Bill Klein
 
Hi Bill,

I think David managed to overun his buffers (in COBOL, no less!).

By the way, what are you doing up at this time? You must be returning from a voting booth or something on the west coast of the US. I David is in Europe, I'm afraid he is already asleep, like most europeans at this time.

Dimandja
 
No, after I made my correction in my code, I didn't check the return status on the DELETE, but I did verify that the file was indeed deleted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top