/* disconn-long-trans.p

Program to disconnect long transactions (more than 2 hr). Intended to be used in cron, i.e. unattended.

7200 seconds = 2 hours

06/26/2007 Dmitri Levin


define variable lv-cmd as character no-undo.

define variable lv-trhold as integer init 7200 no-undo.



  _Trans._Trans-usrnum format ">>>9" label "#"


  _Trans._Trans-Duration  label "Minutes"




 with frame _trans.


for each _Trans where _Trans._trans-num <> ?

  and _Trans._Trans-State = "ACTIVE"

  and _Trans._Trans-Duration > lv-trhold no-lock

   by _Trans._Trans-Duration desc:


  find _connect where _connect._Connect-usr = _Trans._Trans-usrnum

    no-lock no-error.


  display _Trans._Trans-usrnum

    _Connect-Name when avail _connect

    _Trans._Trans-Duration / 60 @ _Trans._Trans-Duration


    substring( _Connect-Device,6) when avail _connect @ _Connect-Device


    with down frame _trans.

    down with frame _trans.


  lv-cmd = "$DLC/bin/proshut your-database-name -C disconnect " +


  os-command silent value( lv-cmd ).