更新 rpgle 中的键值时处理指针

发布于 2024-08-30 04:22:29 字数 919 浏览 3 评论 0原文

我的代码是这样的:

femp        uf   e           k disk                   
dvar1             s              5p 0                
c     *loval        setll     emp                   
c                   read      emp                   
c                   dow       not %eof(emp)         
C                   eval      ecode = ecode + 10     
c                   eval      var1=ecode             
c                   update    recemp               

c     var1          setgt     emp                   
c                   read      emp                   
c                   enddo                            
c                   eval      *inlr=*on

这是一个名为 emp 的文件,其记录格式名称为 recemp,以 ecode 为键...

现在,当我读取该文件,然后在不使用 setgt 的情况下更新 ecode 时...指针没有向前移动,它是多次更新相同的 ecode 值...

现在,当我使用 set gt 指针选择下一条记录时,但当两个 ecode 值相同时它不起作用...否则它也无法使用降序键值...

是否有任何解决方案,以便我可以设置指针,无论值是否相同、升序或降序。

my code goes like this:

femp        uf   e           k disk                   
dvar1             s              5p 0                
c     *loval        setll     emp                   
c                   read      emp                   
c                   dow       not %eof(emp)         
C                   eval      ecode = ecode + 10     
c                   eval      var1=ecode             
c                   update    recemp               

c     var1          setgt     emp                   
c                   read      emp                   
c                   enddo                            
c                   eval      *inlr=*on

Here is a file named emp with record format name recemp with ecode as the key ...

Now when i am reading the file and then updating the ecode without using setgt ..the pointer is not moving ahead it is updating the same ecode value many time ...

Now when i use set gt pointer picks the next record but it dint work when two ecode values are same ...else also it will not be working with descending key values...

Is there any solution so that i can set pointer regardless of the fact whether the values are same or ascending or descending.

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

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

发布评论

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

评论(2

天生の放荡 2024-09-06 04:22:29

您想要更新文件“emp”中每条记录中的“ecode”字段 - 这是正确的吗?
如果是这样,只需使用另一个不带“setgt”的“read”就可以了。

uf e k disk
c *loval setll emp
c read emp
c dow not %eof(emp)
C eval ecode = ecode + 10
c update recemp

c read emp

c enddo
c eval *inlr=*on 

You want to update 'ecode' field in each record in file 'emp' - is that correct?
If so, just use another 'read' without 'setgt' and it will do just fine.

uf e k disk
c *loval setll emp
c read emp
c dow not %eof(emp)
C eval ecode = ecode + 10
c update recemp

c read emp

c enddo
c eval *inlr=*on 
他夏了夏天 2024-09-06 04:22:29

如果要更新每条记录中的键值,则应按到达顺序打开文件(不要使用 F-spec 中的“k”)。另外,不要在循环内使用 SETGT ,除非您专门尝试跳过记录。

If you want to update the key value in every record, you should open the file in arrival sequence (don't use the 'k' in the F-spec). Also, don't use SETGT inside the loop unless you specifically are trying to skip records.

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