Sha256: 8916567b564733f1ff210c756b16200dbc1e8decaac6b9e5071fba3a79cf44a1

Contents?: true

Size: 574 Bytes

Versions: 67

Compression:

Stored size: 574 Bytes

Contents

#!/usr/bin/env ruby

require 'pg'

# An example of how to use SQL cursors. This is mostly a straight port of
# the cursor portion of testlibpq.c from src/test/examples.

$stderr.puts "Opening database connection ..."
conn = PG.connect( :dbname => 'test' )

#
conn.transaction do
    conn.exec( "DECLARE myportal CURSOR FOR select * from pg_database" )
    res = conn.exec( "FETCH ALL IN myportal" )

    puts res.fields.collect {|fname| "%-15s" % [fname] }.join( '' )
    res.values.collect do |row|
        puts row.collect {|col| "%-15s" % [col] }.join( '' )
    end
end

Version data entries

67 entries across 67 versions & 6 rubygems

Version Path
jruby-pg-0.1-java sample/cursor.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/pg-0.20.0/sample/cursor.rb
pg-0.20.0-x86-mingw32 sample/cursor.rb
pg-0.20.0-x64-mingw32 sample/cursor.rb
pg-0.20.0 sample/cursor.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/pg-0.19.0/sample/cursor.rb
pg-0.19.1.pre20170124220800-x64-mingw32 sample/cursor.rb
pg-0.19.1.pre20170124220800-x86-mingw32 sample/cursor.rb
pg-0.19.1.pre20170124220800 sample/cursor.rb
pg-0.19.1.pre20170115074000-x64-mingw32 sample/cursor.rb
pg-0.19.1.pre20170115074000-x86-mingw32 sample/cursor.rb
pg-0.19.1.pre20170115074000 sample/cursor.rb
pg-0.19.0.pre20170115074000 sample/cursor.rb
pg-0.19.0-x86-mingw32 sample/cursor.rb
pg-0.19.0-x64-mingw32 sample/cursor.rb
pg-0.19.0 sample/cursor.rb
pg-0.19.0.pre20160904200247-x86-mingw32 sample/cursor.rb
pg-0.19.0.pre20160904200247-x64-mingw32 sample/cursor.rb
pg-0.19.0.pre20160904200247 sample/cursor.rb
pg-0.19.0.pre20160820113039-x86-mingw32 sample/cursor.rb