Sometimes it would be nice to inform the user about who has locked which record in a table. To do so we need to determined who we are in terms of PostgreSQL connection ids.

Step-by-step guide

  1. Depending on the scenario you need to determine
    1. image-name: use appname()
    2. process-id: The process id can be retrieved using the WIN32 GetCurrentProcessId() API
    3. computername: The workstation name can be retrieved via GetEnv("computername")
  2. In case multiple workstations are connected to the PostgreSQL server use SELECT * FROM "alaska-software.system.connections" WHERE workstation='<computername>'
  3. In case of RDP scenario, multiple processes per server use   SELECT * FROM "alaska-software.system.connections" WHERE process='<image-name>#process-id'
  4. The column connection_id is the id which is used as a lock_owner in the ISAM emulation

Note all values (computername, process and usrename) are always lower case.