Received: from antares.mcs.anl.gov (mcs.anl.gov [140.221.9.6]) by hub.org (8.9.3/8.9.1) with SMTP id QAA24010 for ; Wed, 21 Apr 1999 16:36:20 -0400 (EDT) (envelope-from selkovjr@xnet.com) Received: from xnet.com (selkovjr@selkovjr.xnet.com [205.243.141.67]) by antares.mcs.anl.gov (8.6.10/8.6.10) with ESMTP id PAA20785; Wed, 21 Apr 1999 15:36:13 -0500 Message-Id: <199904212036.PAA20785@antares.mcs.anl.gov> To: JT Kirkpatrick , pgsql-interfaces@hub.org From: "Gene Selkov, Jr." Subject: Re: [SQL] perl and postgres. . . In-Reply-To: Your message of "Wed, 21 Apr 1999 12:12:07 EDT." <01BE8BF0.2DAA4CE0.jt-kirkpatrick@mpsllc.com> Date: Wed, 21 Apr 1999 15:36:08 -0400 Sender: selkovjr@xnet.com > I am trying > $query="select max((userseq) from dataentry;"; > $result=$conn->exec("$query"); > $userseq=($result->getvalue(0,0)); > > * I need the value in a variable name other than $result. . . > > If I try > $query="select max((userseq) from dataentry;"; > $result->getvalue(0,0); > $userseq=$result; > > it bombs. Ahhh, the frustrations of being new to this! Now I see what your problem is. You missed the whole point. $result is not a variable, it is an object reference, so is $conn. The exec() method of $conn (or rather, that of the object referenced by $conn) returns the result object. You normally access the object's data through its methods, in this case, getvalue(), fetchrow(), etc. -- see the Pg doc for the full list. So the following simply copies the reference to the result object into $userseq, and that may bomb, depending on how you use it further: > $userseq=$result; The following the value you need, but it since there is no explicit assignment, it is getting lost: > $result->getvalue(0,0); What you needed was $userseq = $result->getvalue(0,0); And again, the manual for Pg has complete examples. Note the code you need to add to check for errors that may result from each method call. --Gene