Perl interface "oddity" ... - Mailing list pgsql-interfaces

From The Hermit Hacker
Subject Perl interface "oddity" ...
Date
Msg-id Pine.BSF.4.05.9903271517220.6652-100000@thelab.hub.org
Whole thread Raw
List pgsql-interfaces
Just wrote this function for some code I'm writing, and the results I'm
getting back are incorrect...and I can't figure out what I'm screwing up:

============
sub get_fullname {
  my $conn = shift;
  my $userid = shift;

  my $GET_FULLNAME = "\
SELECT ( first_name || ' ' ) || last_name \
  FROM reg_view \
 WHERE userid = '%s';";

  my $str = sprintf($GET_FULLNAME, $userid);
  my $res = $conn->exec($str);
  print STDERR $res->ntuples, "\n";
  if(PGRES_TUPLES_OK != $res->resultStatus) {
    print "User $userid does not exist\n";
    exit;
  }
  @tm = localtime(time);
  $currtime = sprintf("%02d:%02d:%02d", $tm[2], $tm[1], $tm[0]);
  $dateToday = $tm[5] . "_" . ($tm[4] + 1) . "_" .  $tm[3] . "-" .
$currtime;

  $fullname = $res->getvalue(0,0);
  $fullname =~ s/\s+/_/g;

  $ret = "answers/" . $fullname . "_" . $dateToday;
  return $ret;
}
===============

The problem is that altho $res->ntuples is coming back as 1 (which I
expect), the "if(PGRES_TUPLES_OK.." line is failing ...

If I comment out that line, everything works as expected...I get the right
values back for $fullname and everything ... so, I am getting an answer
from the backend, but $res->resultStatus is coming back with '2' as its
result, which, according to the code above, appear to be not equal to
PGRES_TUPLES_OK ...

What am I missing? :(


Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org


pgsql-interfaces by date:

Previous
From: Wojciech Kromer
Date:
Subject: PsqlODBC and 'lo' type in PostrgreSQL 6.4.x
Next
From: Herouth Maoz
Date:
Subject: Re: [INTERFACES] Questions about pq library and ecpg