Page 1 of 1

Rewrite without prior read with update

PostPosted: Wed Nov 06, 2013 4:36 pm
by pulsar22
Hi,

Can we rewrite a record in a file withour readin that record with update option, by just mentioning the record key.

Re: Rewrite without prior read with update

PostPosted: Wed Nov 06, 2013 5:42 pm
by Robert Sample
What did the CICS Application Programming Reference manual tell you when you looked up the REWRITE command?

Re: Rewrite without prior read with update

PostPosted: Wed Nov 06, 2013 10:57 pm
by dick scherrer
Hello,

Do read the manual for a better understanding.

But logically, how might you update something you don't "have" . . .

Are you trying to save some overhead? If so (and there are mostly adds rather than updates) try to add the record and if it is a duplicate, then read and update. If the process is mostly updaes, read then update.

Re: Rewrite without prior read with update

PostPosted: Thu Nov 07, 2013 4:19 pm
by pulsar22
Yes, the program manual told that a rewrite should be done after read of the record to be modified, but my doubt is why can't we edit/rewrite a record directly by mentioning record key like we do in case of delete.

Re: Rewrite without prior read with update

PostPosted: Thu Nov 07, 2013 5:14 pm
by BillyBoyo
Because, as the manual has indicated, that is the way that it works. If there was a REPLACE you might expect it to work like you want.

Re: Rewrite without prior read with update

PostPosted: Thu Nov 07, 2013 5:53 pm
by Robert Sample
why can't we edit/rewrite a record directly by mentioning record key like we do in case of delete
Because the manual tells you that this cannot be done. That is the reason why -- if you want to know more about the reasons behind this restriction, you can ask IBM but don't be surprised if they refuse to tell you (if they even know after so many years).

Re: Rewrite without prior read with update

PostPosted: Thu Nov 07, 2013 11:04 pm
by c62ap90
The UPDATE parameter in the READ first verifies existence of record and if so, then puts your record in exclusive-use for updating fields/data.

As to why not REWRITE? Well, it won't work.

Re: Rewrite without prior read with update

PostPosted: Thu Nov 07, 2013 11:22 pm
by dick scherrer
And this is Not a problem - it is a feature.

This has been the way for a very long time and i suspect it will not change in my time with IT . . . ;)