Page 1 of 1

Reading and updating a file

PostPosted: Thu Jul 10, 2008 3:16 pm
by ram23bal
Hi All,

Is there any way to UPDATE a Variable Block file and WRITE in the same file.
If so plz provide me the syntax.

I tried to read the VB file but I gor the error message


Re: Reading and updating a file

PostPosted: Fri Jul 11, 2008 12:55 am
by dick scherrer

You can read or write a qsam file, but not update records in it. It does not depend on fixed/variable.

Re: Reading and updating a file

PostPosted: Sat Jul 12, 2008 4:58 pm
by jayind
Hi ram23bal,

Suggestion: If you are not aware of the suggestion i am giving below and If you still want to have updated info in the same file...

1. Create a temporary file with the same parameters as the original file
2. read a record from original file
3. modify/update record contents as you wanted
4. Write updated record into temporary file. Continue steps 2 to 4 till the end of original file
5. Delete the existing original file and recreate it with the same parameters. I suggeste to keep a backup before deleting.
6. copy the temporary file contents into the recreated original file

Hope this helps...