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

class TestIbmDb2 < Test::Unit::TestCase

  def test_133
    assert_equal expected, capture {
      sql =  "INSERT INTO animals (id, breed, name, weight)
        VALUES (?, ?, ?, ?)"
      
      conn = DB2::connect(database, user, password)
      
      if !conn
        die("Connection failed.\n")
      end
      
      stmt = DB2::prepare(conn, sql)
      res = DB2::execute(stmt, {128, 'hacker of human and technological nature', 'Wez the ruler of all things PECL', 88.3})
      var_dump(res)
      puts "SQLSTATE: #{DB2::stmt_error(stmt)}"
      puts "\nMessage: #{DB2::stmt_errormsg(stmt)}"
      
      stmt = DB2::prepare(conn, "SELECT breed, name FROM animals WHERE id = ?")
      res = DB2::execute (stmt, {128})
      row = DB2::fetch_assoc(stmt)
      print_r(row)
    }
  end

end

__END__
PHP Warning:  db2_execute(): Statement Execute Failed in %stest_133.php on line %d
bool(false)
SQLSTATE: 22001
Message: [IBM][CLI Driver] CLI0109E  String data right truncation. SQLSTATE=22001
