Sha256: 313a9cc4b90de349c19fde53192b6a593dda50aa39c0e4f489594cd01a21875f

Contents?: true

Size: 792 Bytes

Versions: 4

Compression:

Stored size: 792 Bytes

Contents

#!/usr/bin/env ruby

$:.unshift(File.join(File.dirname(__FILE__), "../../lib"))
$:.unshift(File.join(File.dirname(__FILE__), "../../test"))

require 'Assert'
require 'sqlpostgres'

include SqlPostgres
include Assert

Connection.open do |connection|

  connection.exec("create temporary table foo (i int)")

  # Example: ../../lib/sqlpostgres/Savepoint.rb
  Transaction.new(connection) do

    insert = Insert.new('foo', connection)
    insert.insert('i', 1)
    insert.exec

    Savepoint.new('bar', connection) do |sp|
      insert = Insert.new('foo', connection)
      insert.insert('i', 2)
      sp.abort
    end

    insert = Insert.new('foo', connection)
    insert.insert('i', 3)
    insert.exec

  end

  p connection.query("select i from foo order by i") #OUTPUT
  # End example

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sqlpostgres-1.3.0 doc/examples/savepoint.rb
sqlpostgres-1.2.6 doc/examples/savepoint.rb
sqlpostgres-1.2.5 doc/examples/savepoint.rb
sqlpostgres-1.2.4 doc/examples/savepoint.rb