/*
 * call-seq:
 *    res.value( tup_num, field_num )
 *
 * Returns the value in tuple number <i>tup_num</i>, field number <i>field_num</i>. (Row <i>tup_num</i>, column <i>field_num</i>.)
 *
 * Equivalent to <tt>res.result[tup_num][field_num]</tt> (but faster).
 */
static VALUE
pgresult_getvalue(obj, tup_num, field_num)
  VALUE obj, tup_num, field_num;
{
  PGresult *result;
  int i = NUM2INT(tup_num);
  int j = NUM2INT(field_num);

  result = get_pgresult(obj);
  if (i < 0 || i >= PQntuples(result)) {
  rb_raise(rb_eArgError,"invalid tuple number %d", i);
  }
  if (j < 0 || j >= PQnfields(result)) {
  rb_raise(rb_eArgError,"invalid field number %d", j);
  }

  return fetch_pgresult(result, i, j);
}