class TestIbmDb2 < Test::Unit::TestCase

  def test_042
    assert_expect {
      conn = DB2::connect db,username,password
      #_GET['EMPNO'] = '000130'
      if isset(_GET['EMPNO'])
        result = DB2::exec conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='gif' and empno='" + _GET['EMPNO'] + "'"
        row = DB2::fetch_array result
        if row
          # We'll be outputting a         
          header('Content-type: image/' + row[0])
          header('Content-Length: ' + row[2])
          print row[1]
        else
          print DB2::error()
        end
        next
      else
        result = DB2::exec conn, "select EMPNO, PHOTO_FORMAT from emp_photo where photo_format='gif'"
        while (row = DB2::fetch_array(result))
          printf("<a href='test_042.php?EMPNO=%s' target=_blank>%s (%s)</a><br>",row[0], row[0], row[1])
          puts ""
        end
      end
    }
  end

end

__END__
<a href='test_042.php?EMPNO=000130' target=_blank>000130 (gif)</a><br>
<a href='test_042.php?EMPNO=000140' target=_blank>000140 (gif)</a><br>
<a href='test_042.php?EMPNO=000150' target=_blank>000150 (gif)</a><br>
<a href='test_042.php?EMPNO=000190' target=_blank>000190 (gif)</a><br>

