HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Using READ/DELETE

 
Jack Trachtman
Super Advisor

Using READ/DELETE

I have an indexed file with one key, but which allows duplicate records for that key.

If I READ/KEY=0/INDEX=nnnn to get the first record with that key, I can then delete that record via READ/DELETE.

If I use READ/KEY=0/INDEX=nnn to get to the first record, then issue some number of simple READs to move ahead, I can't seem to then delete that record - the READ/DELETE still seems to delete the first record found.

Can someone give me an example of how to do this, or isn't his possible?

TIA
4 REPLIES
RBrown_1
Trusted Contributor

Re: Using READ/DELETE

I found that READ/DELETE without any /KEY etc would delete the *next* record with the current key. So:

$ READ F R
$ SHOW SYMBOL R
R = "A2"
$ READ/DELETE F R
$ SHOW SYMBOL R
R = "A3"

Then close the file and check and see that record A3 has been deleted.

Not very friendly, but if you have exclusive access to the file you will be able to predict which record will be deleted.

:-|
abrsvc
Respected Contributor

Re: Using READ/DELETE

A little more info is required here to provide you with a reasonable explanation and answer:

1) VMS Version and platform (Alpha,VAX,I64)
2) Application language

Thanks,
Dan
Jack Trachtman
Super Advisor

Re: Using READ/DELETE

Alphaserver
OpenVMS V8.3
DCL
Hein van den Heuvel
Honored Contributor

Re: Using READ/DELETE

Hmmm, I do not see the problem.
See sample below.
Can you show a 'real' mock-up example of the problem? The description you provided is incorrect, because surely you mean "KEY=nnnn/INDEX=0 when you wrote "KEY=0/INDEX=nnnn", as you also indicated it was a one-key file.

Read /Delete will delete the record is is reading and put the contents in the symbol provided. (Such that you can recover with WRITE/SYMB file record :-).

Hein

$ convert tt: tmp.idx/fdl="fil; org ind; key 0; seg0_l 4; dup yes"
0001
0002aap
0002noot
0002mies
0003
Exit
$ open/read/write x tmp.idx
$ read/key="0002"/ind=0 x rec
$ read x rec
$ show symb rec
REC = "0002noot"
$ read/dele x rec ! Should read, and delete 0002mies
$ show symb rec
REC = "0002mies"
$ close x
$ type tmp.idx
0001
0002aap
0002noot
0003