Sha256: 604fb42651cd1dc7abf7d51d4b994d0e296df2748c3b1cef336e049a462c3844

Contents?: true

Size: 569 Bytes

Versions: 118

Compression:

Stored size: 569 Bytes

Contents

# -*- 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

118 entries across 118 versions & 4 rubygems

Version Path
pg-1.5.9-x86-mingw32 sample/cursor.rb
pg-1.5.9-x64-mingw32 sample/cursor.rb
pg-1.5.9-x64-mingw-ucrt sample/cursor.rb
pg-1.5.9 sample/cursor.rb
pg-1.5.8-x64-mingw32 sample/cursor.rb
pg-1.5.8-x64-mingw-ucrt sample/cursor.rb
pg-1.5.8-x86-mingw32 sample/cursor.rb
pg-1.5.8 sample/cursor.rb
pg-1.5.7-x86-mingw32 sample/cursor.rb
pg-1.5.7-x64-mingw32 sample/cursor.rb
pg-1.5.7-x64-mingw-ucrt sample/cursor.rb
pg-1.5.7 sample/cursor.rb
pg-1.5.6-x64-mingw-ucrt sample/cursor.rb
pg-1.5.6-x64-mingw32 sample/cursor.rb
pg-1.5.6-x86-mingw32 sample/cursor.rb
pg-1.5.6 sample/cursor.rb
pg-1.5.5-x86-mingw32 sample/cursor.rb
pg-1.5.5-x64-mingw32 sample/cursor.rb
pg-1.5.5-x64-mingw-ucrt sample/cursor.rb
pg-1.5.5 sample/cursor.rb