如何在不实际阅读rpgle中的记录的情况下删除记录

发布于 2025-02-14 02:00:19 字数 158 浏览 0 评论 0原文

最近,我遇到了一个在RPGLE采访中问我的问题。我被问及如何在不实际阅读rpgle上删除唱片。我的答案是我们可以使用嵌入式SQL,但他在SQL中告诉我们仍在阅读数据。 因此,在这个社区中,如果有人知道“如何在rpgle中删除唱片而不实际阅读记录”,请让我知道,我很高兴知道答案。

提前致谢

Recently I came across a question that was asked to me in a RPGLE interview. I was asked how to delete a record without actually reading it in RPGLE. My answer was we can use embedded SQL , but he told in SQL we are still reading the data.
So in this community if anyone knows "how to delete a record without actually reading it in RPGLE" please let me know, I would be delighted to know the answer.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冰魂雪魄 2025-02-21 02:00:19

因子-1搜索参数

C     MYKLIST       DELETE    MYFILE

您只需提供自由形式的

delete (key1:key2) myfile;

,就在手动

如果未指定搜索参数(搜索 - arg),请删除
操作删除当前记录(检索到最后的记录)。这
记录必须已被以前的输入操作锁定(对于
例如,链或读取)。

搜索参数,搜索-arg,必须是密钥或相对记录
数字 用于检索要删除的记录。 如果访问是键,
搜索-arg可以是字段名称的形式的单个键,
常数,比喻常数或字面的。

如果文件是外部描述的文件,则搜索也可以是一个
klist名称,值列表或%kds的复合键。

我必须承认,我不得不看一下,从头到头,我想:“你不能”。现在,我的记忆已经刷新了,我想我记得在我使用RPG的30年中一次或两次这样做。

请注意,RPGIII有相同的支持。

您的“使用SQL”的答案在我的书中是正确的。假设您谈论的是“搜索”删除,

delete from mytable where ....

而不是“定位”删除,

delete where current of cursor C1

最终您的访调员认为,如果他认为RPG搜索的RPG搜索删除删除不会首先读取记录,而是SQL One确实读取了记录。请注意,引用 的突出显示了 用于检索要删除的记录的部分。

数据库记录必须为阅读以删除。唯一的问题是您通过阅读/链或SQL光标明确阅读它。还是DB通过“搜索”删除为您做的。

You simply provide a factor-1 search argument

C     MYKLIST       DELETE    MYFILE

In free form,

delete (key1:key2) myfile;

It's in the manual
enter image description here

If a search argument (search-arg) is not specified, the DELETE
operation deletes the current record (the last record retrieved). The
record must have been locked by a previous input operation (for
example, CHAIN or READ).

The search argument, search-arg, must be the key or relative record
number used to retrieve the record to be deleted. If access is by key,
search-arg can be a single key in the form of a field name, a named
constant, a figurative constant, or a literal.

If the file is an externally-described file, search-arg can also be a
composite key in the form of a KLIST name, a list of values, or %KDS.

I must admit, I had to look it up, off the top of my head I thought, "you can't". Now that my memory is refreshed, I think I recall doing this once or twice in the 30yrs I've been using RPG.

Note that RPGIII had the same support.

Your answer of "use SQL" would have been correct in my book. Assuming you're talking about the "search" delete

delete from mytable where ....

rather than a "positioned" delete

delete where current of cursor C1

Finally your interviewer is misinformed if he thinks the RPG Searched delete doesn't read the record first but that the SQL one does. Note the highlighted section of the quote used to retrieve the record to be deleted.

A database record has to be read in order to be deleted. The only question is are you reading it explicitly, via READ/CHAIN or an SQL Cursor. Or is the DB doing it for you via "search" delete.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文