Sha256: ee66f6c224677b2249f4ba8566481a1c36074b30c36ba7331782e8de5373b69b

Contents?: true

Size: 1.02 KB

Versions: 17

Compression:

Stored size: 1.02 KB

Contents

#! /usr/bin/env ruby
#
# original file src/test/examples/testlibpq2.c
#                       Test of the asynchronous notification interface
# CREATE TABLE TBL1 (i int4);
# CREATE TABLE TBL2 (i int4);
# CREATE RULE r1 AS ON INSERT TO TBL1 DO (INSERT INTO TBL2 values (new.i); \
#                                         NOTIFY TBL2);
# Then start up this program
# After the program has begun, do
# INSERT INTO TBL1 values (10);


require 'postgres'

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

main

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
ruby-postgres-0.7.1.2005.11.24-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2006.04.06-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2006.04.05-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2005.12.21-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2005.12.20-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2005.12.19-mswin32 sample/test2.rb
ruby-postgres-0.7.1.2005.11.27-mswin32 sample/test2.rb
postgres-0.7.1 sample/test2.rb
ruby-postgres-0.7.1.2005.11.26 sample/test2.rb
ruby-postgres-0.7.1.2005.11.23 sample/test2.rb
ruby-postgres-0.7.1.2005.12.19 sample/test2.rb
ruby-postgres-0.7.1.2005.12.20 sample/test2.rb
ruby-postgres-0.7.1.2005.11.27 sample/test2.rb
ruby-postgres-0.7.1.2005.11.24 sample/test2.rb
ruby-postgres-0.7.1.2006.04.05 sample/test2.rb
ruby-postgres-0.7.1.2005.12.21 sample/test2.rb
ruby-postgres-0.7.1.2006.04.06 sample/test2.rb