简体   繁体   中英

In RPGLE program, Why do EXCEPT is preferred over UPDATE to update a field in PF?

Eval Num = 1;

Why do we prefer:

C  EXCEPT     DDMAST
--------------------------- 
O  RDDMAST   E    DDMAST
O                 NUM

Over:

UPDATE     DDMAST

We don't.

It is really a shop preference. I was going to say EXCPT was easier, but I can't really even justify that in my mind. A lot of folks used EXCPT to output to the printer because it was easier than creating a print file, and sometimes that made it's way to database files as well because it was the same process, but I always preferred WRITE and UPDATE and DELETE over EXCPT, and eventually even stopped using EXCPT for reports as well since you could do more things with a printer file than you could with the program described output specs. These days I don't even use record level IO for database files, preferring SQL.

In 25yrs, I've never seen EXCEPT used for a Physical File. EXCEPT is used for "exception records" defined in the o-specs. I suppose it might make sense to WRITE exceptions to a table rather than a spool file. But I've never seen it.

Honestly, looking at the documentation, it's not even clear that it can be used instead of UPDATE.

A bit of googling turned up a post that indicated EXCEPT could be used to update selected fields in a PF. There is a performance benefit to doing that.

However the modern (though 21yrs old) way to update individual fields only is with the %FIELDS() BIF.

update ddmast %fields(num);

Lastly, you can't (directly) define o-specs in a fully **free RPG IV program.

Using EXCEPT instead of UPDATE would not be allowed in my shop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM