简体   繁体   English

在 RPGLE 程序中,为什么 EXCEPT 优于 UPDATE 来更新 PF 中的字段?

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

Eval Num = 1;评估数 = 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.我本来想说 EXCPT 更容易,但我什至无法在我的脑海中证明这一点。 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.很多人使用 EXCPT 到 output 到打印机,因为它比创建打印文件更容易,有时这也成为数据库文件的方式,因为它是相同的过程,但我总是更喜欢 WRITE 和 UPDATE 和 DELETE 而不是 EXCPT ,甚至最终也停止使用 EXCPT 进行报告,因为您可以使用打印机文件做的事情比使用 output 规范描述的程序做的事情要多。 These days I don't even use record level IO for database files, preferring SQL.这些天来,我什至不将记录级别 IO 用于数据库文件,更喜欢 SQL。

In 25yrs, I've never seen EXCEPT used for a Physical File. 25 年来,我从未见过 EXCEPT 用于物理文件。 EXCEPT is used for "exception records" defined in the o-specs. EXCEPT 用于 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.老实说,查看文档,甚至不清楚是否可以使用它来代替 UPDATE。

A bit of googling turned up a post that indicated EXCEPT could be used to update selected fields in a PF.谷歌搜索了一下,发现了一个帖子,指出 EXCEPT 可用于更新 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.然而,仅更新单个字段的现代(尽管已有 21 年历史)方法是使用%FIELDS() BIF。

update ddmast %fields(num);

Lastly, you can't (directly) define o-specs in a fully **free RPG IV program.最后,您不能(直接)在完全**free的 RPG IV 程序中定义 o-specs。

Using EXCEPT instead of UPDATE would not be allowed in my shop.我的商店不允许使用 EXCEPT 而不是 UPDATE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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