Progress 4GL显示缓冲区锁定类型 [英] Progress 4GL Display Buffer Lock Type

查看:102
本文介绍了Progress 4GL显示缓冲区锁定类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问一下是否有一种方法可以在消息框中显示缓冲区的当前锁定类型.有没有办法做到这一点?

I would like to ask if there is a way to display the current lock type of my buffer in a message box. Is there a way to do this?

我只想检查运行时缓冲区上的锁类型.

I just want to check what type of lock there is on my buffer on run time.

例如:MESSAGE STRING(myBuffer:LOCK-TYPE).
输出:NO-LOCK/SHARE-LOCK/EXCLUSIVE-LOCK

For example: MESSAGE STRING(myBuffer:LOCK-TYPE).
Output: NO-LOCK/SHARE-LOCK/EXCLUSIVE-LOCK

推荐答案

不直接.

您可以使用LOCKED(bufferName)函数(或缓冲区句柄对象的相关属性)来查看它是否被锁定,但是您无法以这种方式区分SHARE和EXCLUSIVE.

You can use the LOCKED( bufferName ) function (or the related attribute of a buffer handle object) to see if it is locked or not but you cannot distinguish between SHARE and EXCLUSIVE that way.

真的应该足够了-如果它没有锁定,那么您不会对其他人造成任何问题.如果它是锁定的,则无论是共享的还是互斥的,其他任何人都无法锁定它.如果您最初要求它排他锁,那是您的享受.如果您未能指定锁类型,或者您明确表示SHARE-LOCK且现在想升级锁,则应使用FIND CURRENT表EXCLUSIVE-LOCK.如果获得升级,则具有独占锁.如果不是,则为NO-LOCK或SHARE-LOCK(您可以从以前的测试中知道).

Really that ought to be enough -- if it is not locked then you are not causing any issues for other people. If it is locked, regardless of shared or exclusive, then nobody else can lock it. It is yours to enjoy if you originally asked for it EXCLUSIVE-LOCK. If you failed to specify a lock type or if you explicitly said SHARE-LOCK and now want to upgrade the lock you should use FIND CURRENT table EXCLUSIVE-LOCK. If you get the upgrade you have an exclusive lock. If not then it was either NO-LOCK or SHARE-LOCK (which you would know from your previous test).

从理论上讲,您也许可以扫描_LOCK VST并解析其中的信息,但这与一个简单的函数相距很远,该函数可能满足用"just"一词表示的要求:)

In theory you might be able to scan the _LOCK VST and parse the information therein but that is a long ways from a simple function that might meet a requirement stated with the word "just" :)

这也是非常危险的-_LOCK VST易失性(输入和输入的速度比读取速度快),并且很容易编写似乎在开发中工作但会占用大量CPU时间的代码在生产情况下.不要尝试.结局不会很好.

It is also very dangerous -- the _LOCK VST is volatile (entries come and go faster than they can be read) and it is very easy to write code that seems to work in development but that chews up vast amounts of CPU time in production situations. Do NOT try it. It will not end well.

如果您坚持不理我,至少从这样创建的快照中进行工作:

If you insist on ignoring me at least work from a snapshot created like so:

define variable i as integer no-undo.

define temp-table tt_lock no-undo like _lock
  index id-idx is unique primary _lock-id
  index recid-idx _lock-recid
  index usr-idx _lock-usr
  index tbl-idx _lock-table
.

empty temp-table tt_lock.

for each _lock while _lock._lock-usr <> ?:

  i = i + 1.
  if i > 10000 then leave.

  create tt_lock.
  buffer-copy _lock to tt_lock no-error.

end.

请注意在FOR EACH中使用WHILE.如果您不理我,尝试这种方法,请您尝试一下.您会发现WHILE比使用WHERE标准所能做的任何事情都要快得多.

Note the use of WHILE in the FOR EACH. If you ignore me and try this approach I urge you to experiment. You will discover that WHILE is much faster than anything you might do with WHERE criteria.

如果i> 10000,则离开."是州长.任何代码中都应该有类似_LOCK的内容.这样可以防止它在带有大型锁定表的PROD系统上意外发疯.

The "if i > 10000 then leave." is a governor. You should have something similar in any code that toucjes _LOCK. It prevents it from accidentally going crazy on PROD systems with large lock tables.

无论您认为要执行多少操作,都在犯错误.请不要去那里.如果您想了解这些问题,或者正在开发环境中查看问题,请进行实验,但是请不要在生产环境中使用这种代码.

No matter how much you think you want to do this you are making a mistake. Please don't go there. Experiment if you want to understand the issues or you are looking at a problem in your dev environment but please don't put this kind of code in production.

这篇关于Progress 4GL显示缓冲区锁定类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆