HP OpenVMS Systemsask the wizard |
The Question is: Is there a way to edit a file that is in a relative organized file? The Answer is : There is no standard OpenVMS utility that can accomplish the task of (directly) editing a relative-format file. There are data manipulation products (DATATRIEVE, ACCELR) for sale and potentially freeware that may help. The OpenVMS Wizard would encourage you to write a simple program in the language of your choice (either a compiled language, DCL, or otherwise) to perform the required edits while maintaining the file integrety from the perspective of the file contents. Alternatively, write a tool that can export the data into a (sequential) file that can be edited, and a tool that then imports the data into the appropriate format. For INDEXED files containing (only) text data, you can potentially edit the file with a regular text editor and reconverting the output back to indexed using an FDL description obtained from the original. There are caveats with this: order of duplicates, and you must be exceedingly careful to avoid altering other data or other columns in the file. For RELATIVE files, a sequential view of the file as seen by a regular text editor or 'TYPE' commands will drop the cell-level information. In other words, the file will be packed and all records will appear densely populated (in adjacent cells) while the relative file may actually have been sparely populated. As long as the input file was tightly packed, with no deleted records or empty record cells, then you can reconvert the edited contents, but such simple cases are rare applications. For occasional edits or data recovery purposes on relative-format and indexed-format files, the most common tool is often a simple (and custom-written) DCL command procedure. Using the WRITE/UPDATE command, you can update a previously read record IN PLACE. Using READ/DELETE you can remove record, but you can not add new records (no WRITE/KEY) To read the target record, either use sequential reads (READ with no argument other than handle and buffer) until the right count or contents is seen. Or... use KEYed reads, but those are tricky at best due to the BINARY nature of relative file record numbers. Some sample manipulations are included below. The output is based on a file loaded with record 1,5 and 9 using the included simple BASIC load program. Use DUMP/RECORD[=(star:nn,count:mm)] to verify the CELL number in the RFA. $ create/fdl=sys$input tmp.rel file; organization relative record; size 80 $ run load $ open/read/write x tmp.rel $ read x rec $ show sym rec $ read x rec $ show sym rec $ write /update x "hello there" $ close x $ typ tmp.tmp aap test hello there mies test $ dump/rec tmp.tmp Record number 1 (00000001), 80 (0050) bytes, RFA(0001,0000,0000) 20202020 20202020 20202020 20706161 aap 000000 20202020 20202020 74736574 20202020 test 000010 20202020 20202020 20202020 20202020 000020 20202020 20202020 20202020 20202020 000030 20202020 20202020 20202020 20202020 000040 Record number 2 (00000002), 11 (000B) bytes, RFA(0005,0000,0000) 657265 6874206F 6C6C6568 hello there..... 000000 Record number 3 (00000003), 80 (0050) bytes, RFA(0009,0000,0000) 20202020 20202020 20202020 7365696D mies 000000 20202020 20202020 74736574 20202020 test 000010 20202020 20202020 20202020 20202020 000020 20202020 20202020 20202020 20202020 000030 20202020 20202020 20202020 20202020 000040 $ open/read/write x tmp.tmp $ key="1234" $ key[0,32]=5 $ read/key=&key x rec $ show symb rec REC = "hello there" $ key[0,32]=6 $ read/key=&key x rec %RMS-E-RNF, record not found $ write/update x "Hmmmm...." %RMS-F-CUR, no current record (operation not preceded by $GET/$FIND) $ type load.bas open "tmp.rel" as file #1, recordtype any, ORGANIZATION RELATIVE, map x map (x) string x=20, y=20 y = "test" input "record number"; i while i input "record data"; x put #1, record i input "next record"; i next close #1
|