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

class TestIbmDb2 < Test::Unit::TestCase

  def test_142
    assert_equal expected, capture {
      sql = "SELECT id, breed, name, weight
        FROM animals
        WHERE weight < ? AND weight > ?"
      
      conn = DB2::connect(database, user, password)
      
      if conn
        stmt = DB2::prepare(conn, sql)
      
        DB2::bind_param(stmt, 1, 'weight', DB2::PARAM_IN)
        DB2::bind_param(stmt, 2, 'mass', DB2::PARAM_IN)
      
        weight = 200.05
        mass = 2.0
      
        if DB2::execute(stmt)
          while (row = DB2::fetch_{stmt})
            var_dump(row)
          end
        end
        DB2::close(conn)
      else
        puts"Connection failed.\n"
      end
    }
  end

end

__END__
array(4) {
  [0]=>
  int(0)
  [1]=>
  string(3) "cat"
  [2]=>
  string(16) "Pook            "
  [3]=>
  string(4) "3.20"
}
array(4) {
  [0]=>
  int(1)
  [1]=>
  string(3) "dog"
  [2]=>
  string(16) "Peaches         "
  [3]=>
  string(5) "12.30"
}
array(4) {
  [0]=>
  int(5)
  [1]=>
  string(4) "goat"
  [2]=>
  string(16) "Rickety Ride    "
  [3]=>
  string(4) "9.70"
}
array(4) {
  [0]=>
  int(6)
  [1]=>
  string(5) "llama"
  [2]=>
  string(16) "Sweater         "
  [3]=>
  string(6) "150.00"
}
