View previous topic :: View next topic
|
Author |
Message |
Mariraj
New User
Joined: 09 Jul 2007 Posts: 59 Location: Chennai
|
|
|
|
Can we rewrite an indexed file without a prior read. I believe we can do it when we open the file is accessed using RANDOM/DYNAMIC mode. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Programming Guide manual, with emphasis added by me:
Quote: |
1.10.3.6 Replacing records in a VSAM file
To replace a record in a VSAM file, use REWRITE on a file that you opened as I-O. If the file was not opened as I-O, the record is not rewritten and the status key is set to 49. Check the file status key after each REWRITE statement.
For sequential files, the length of the replacement record must be the same as the length of the original record. For indexed files or variable-length relative files, you can change the length of the record you replace.
To replace a record randomly or dynamically, you do not have to first READ the record. Instead, locate the record you want to replace as follows:
* For indexed files, move the record key to the RECORD KEY data item, and then issue the REWRITE.
* For relative files, move the relative record number to the RELATIVE KEY data item, and then issue the REWRITE. |
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
How come you always know where to look in the Manual/s, Robert! ;) |
|
Back to top |
|
|
Mariraj
New User
Joined: 09 Jul 2007 Posts: 59 Location: Chennai
|
|
|
|
Thanks Robert. It is good that he knows where to look in the manual . I looked into the cobol language reference before posting this query. But it wasn't as explicit as the above stated line. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Anuj, I've had to look up a LOT over the years, so I've learned the manuals well. This is one of the better skills to develop -- I always tell people, I don't know everything, but I know where to find it! |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Mariraj P., the Language Reference guide has the syntax, whereas the Programming Guide tends to have the implementation details. This isn't a perfect split, though, so if you look in one manual and don't find what you're needing to know, look in the other one. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
But try to look up the syntax for COBOL reference modification if you don't know that's what it is called. I do not remember ":" being in the index. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
FYI,
You can also find Reference Modification listed in the COBOL Language Reference Manual Index under it's CLIST/REXX nomenclature - i.e. SUBSTRing. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Ronald - I never thought of that, as I knew "substr" was not the COBOL syntax.
I don't have a hardcopy anymore, but searching the manuals at the top - all 3 COBOL language refs - none has "substr" at the top-level (table of contents), but the Enterprise one does at least have "reference modification".
Its index, however, has "reference-modification" (with hyphen).
So, not particularly user friendly for this language element. |
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Phil,
My only reason for posting a response about "reference modification" was to show that "sometimes" alternative search criteria can actually lead to the topic someone is searching for. True, even when using a web search facility.
I myself have been known to do a (PDF) text search of an entire document when I "know" the "context" but not the actual, not so obvious, "tag" that was selected by the document's author for the TOC/index. |
|
Back to top |
|
|
|