def main
pghost = nil
pgport = nil
pgoptions = nil
pgtty = nil
dbname = ENV['USER']
begin
conn = PGconn.connect(pghost,pgport,pgoptions,pgtty,dbname)
rescue PGError
printf(STDERR, "Connection to database '%s' failed.\n",dbname)
exit(2)
end
begin
res = conn.exec("LISTEN TBL2")
rescue PGError
printf(STDERR, "LISTEN command failed\n")
exit(2)
end
res.clear
while 1
notify = conn.get_notify
if (notify)
printf(STDERR,"ASYNC NOTIFY '%s' from backend pid '%d' received\n",notify[0],notify[1])
break
end
end
end