请教:锁等待时间如何设置?
请教各位高人,as 400中等待解锁的时间如何设置,如果有一个进程已经对一个文件或者数据进行加锁,另外一个进程试图访问时会一直在等待,如何让第二个进程不等待,马上报错退出?我在网上搜了一下,有说用set current lock timeout语句的,但系统不支持,又说修改locktimeout参数的,但我不知道在哪里修改,请各位指教。不胜感激!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
本帖最后由 insmile 于 2010-11-05 13:12 编辑
If you do not want the job to wait for the record to become available, specify WAITRCD(*IMMED)
有两个参数
Maximum file wait time . . . . . 30 Seconds, *IMMED, *CLS
Maximum record wait time . . . . 60 Seconds, *NOMAX, *IMMED
一个是文件锁的,一个记录锁的
*IMMED
程序不等待。要求立即分配文件资源。
*IMMED
程序不等待;当一个记录被锁定时,需要立即分配记录
被锁后要报错退出应该判断文件状态或记录状态,以上两个参数不能改成*IMMED ,默认好了
C* Error retrieving record
C WHEN %ERROR
C* Record lock error
C IF %STATUS = 1218
符合这些条件就退出处理
。。。。C语言的不知道怎么写
谢谢insmile ,我改了文件的WAITRCD值还是不行,是不是因为我用的C语言程序,不是RPG程序,测试方法如下:我用chgpf把文件ftpsrc/cardfile的WAITRCD改成*immed,然后开一屏用EDTF FILE(ftpsrc/cardfile) mbr(kh10299)编辑这个文件,然后用另一屏调用程序试图打开这个文件,依然不会马上报错,程序停留在fopen位置,把第一屏编辑文件的界面退出,程序就接着往下走了。
How can we keep an RPG program from freezing up when it tries to randomly read a record that is locked by another job? -- Andy
That is a very good question, Andy. I assume you're already checking to make sure that the record was found. You can add a similar check for an error condition. Code an indicator in the LO resulting indicator position.
The following RPG code illustrates this technique:
FCUSTOMERUF E K DISK
F KINFDS INFO
I SDS
I 91 170 ERRMSG
IINFO DS
I *STATUS FSTAT
** HILOEQ
C CUSKEY CHAINCUSTREC 4142
C SELEC
C *IN42 WHEQ *ON
.... put record-locked logic here
C *IN41 WHEQ *ON
.... put record-not-found logic here
If the record is locked, the system turns on indicator 42 and loads an error message into positions 91 through 170 of the program status data structure. The message looks like this:
Record 5 in use by job 185008/SMITH/SMITHJOB.
Also, the system will place the value 01218 in the *STATUS subfield (positions 11 through 15) of the file information data structure.
If you're using RPG IV, you can throw away the indicators. Use the E operation extender on the chain op code to tell RPG to signal an error, and follow with a test for the %ERROR and %STATUS built-in functions. Here's an example:
FCUSTOMER UF E DISK
DSDS SDS
D ERRMSG 91 170
C CUSKEY CHAIN(E) CUSTREC
C SELECT
C* Error retrieving record
C WHEN %ERROR
C* Record lock error
C IF %STATUS = 1218
C ENDIF
C WHEN %FOUND
C UPDATE CUSTREC
C OTHER
C ENDSL
The delay time is an attribute of the database file. The default is 60 seconds. Use the Maximum Record Wait Time (WAITRCD) parameter of the Create Physical File (CRTPF), Change Physical File (CHGPF), or Override with Database File (OVRDBF) commands to adjust this value. If you do not want the job to wait for the record to become available, specify WAITRCD(*IMMED), as this override command illustrates:
OVRDBF FILE(CUSTOMER) WAITRCD(*IMMED)
I want to thank Barbara Morris of IBM Toronto for her assistance in working up this tip.
-- Ted
come here:http://www.itjungle.com/guruo/mgo011802-story02.html
本帖最后由 insmile 于 2010-11-04 22:20 编辑
如果是dds建立的就在编译pf的时候选择一个参数
现在没有环境,不记得是哪个了,lz自己找找,按F10看看附加参数里面,一般默认是60秒
WAITRCD Maximum record wait time Integer, 60, *IMMED, *NOMAX
http://publib.boulder.ibm.com/in ... c=%2Fcl%2Fcrtpf.htm