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

class TestIbmDb2 < Test::Unit::TestCase

  def test_020
    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, DB2::AUTOCOMMIT_OFF )
        ac = DB2::autocommit( conn )
        if( ac != 0 )
         puts"Cannot set DB2::AUTOCOMMIT_OFF\nCannot run test\n"
         exit
        end
        
        DB2::exec( conn, "DELETE FROM animals" )
        
        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
0
7
