Perl interface "oddity" ...

From: The Hermit Hacker <scrappy(at)hub(dot)org>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Perl interface "oddity" ...
Date: 1999-03-27 19:22:44
Message-ID: Pine.BSF.4.05.9903271517220.6652-100000@thelab.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)hub(dot)org secondary: scrappy(at){freebsd|postgresql}.org

Browse pgsql-interfaces by date

  From Date Subject
Next Message Herouth Maoz 1999-03-28 16:37:28 Re: [INTERFACES] Questions about pq library and ecpg
Previous Message Wojciech Kromer 1999-03-27 17:45:19 PsqlODBC and 'lo' type in PostrgreSQL 6.4.x