require 'ibm_db2'
require 'stringio'
require 'test/unit'

class TestIbmDb2 < Test::Unit::TestCase

  def test_022
    assert_equal expected, capture {
      conn = DB2::connect(database, user, password)
      
      if conn
        stmt = DB2::exec( conn, "SELECT count(*) FROM animals" )
        res = DB2::fetch_{ stmt }
        rows = res[0]
        putsrows."\n"
        
        DB2::autocommit( conn, 0 )
        ac = DB2::autocommit( conn )
        if( ac != 0 )
         puts"Cannot set DB2::AUTOCOMMIT_OFF\nCannot run test\n"
         exit
        end
        
        DB2::exec( conn, "INSERT INTO animals values (7,'bug','Brain Bug',10000.1)" )
        
        stmt = DB2::exec( conn, "SELECT count(*) FROM animals" )
        res = DB2::fetch_{ stmt }
        rows = res[0]
        putsrows."\n"
        
        DB2::rollback( conn )
        
        stmt = DB2::exec( conn, "SELECT count(*) FROM animals" )
        res = DB2::fetch_{ stmt }
        rows = res[0]
        putsrows."\n"
        DB2::close(conn)
      else
        puts"Connection failed.\n"
      end
    }
  end

end

__END__
7
8
7
