Sha256: 92fc497701d4f8a47eaf5d3b83dc84256139bec0f2c41c66990d0491b9e503fd

Contents?: true

Size: 589 Bytes

Versions: 3

Compression:

Stored size: 589 Bytes

Contents

# -*- ruby -*-

require 'yugabyte_ysql'

# 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 = YugabyteYSQL.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

3 entries across 3 versions & 1 rubygems

Version Path
yugabyte_ysql-0.3 sample/cursor.rb
yugabyte_ysql-0.2 sample/cursor.rb
yugabyte_ysql-0.1 sample/cursor.rb