Here you are the simple procedure, which shows all connections and locks applied by them:
/* connusr.p */
/* BogdanB - procedure displays list of processes
actually connected to db */
def var tableName as char no-undo.
for each _Connect
no-lock /*,
each _User
where _User._Userid = _Connect._Connect-Name
no-lock */ :
if _Connect._Connect-Usr = ? then
next.
display
_Connect._Connect-Id
_Connect._Connect-Usr
_Connect._Connect-Type
_Connect._Connect-Name
_Connect._Connect-Pid
with centered .
for each _Lock
no-lock
on error undo, leave
on stop undo, leave:
if _Lock._Lock-Usr = ? then
leave.
if _Lock._Lock-Usr <> _Connect._Connect-Usr then
next.
find _File
where _File._File-Number = _Lock._Lock-Table
no-lock no-error.
if not avail(_File) then
tableName = "ERROR: no table!".
else
tableName = _File._File-Name.
display
_Lock._Lock-Type
tableName format "X(32)"
_Lock._Lock-RecId
_Lock._Lock-Flags
with centered .
end.
end.
pause.
quit.
Hope it helps.
Bogdan