pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brett W. McCoy <bmccoy@lan2wan.com>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-interfaces@hub.org' <pgsql-interfaces@hub.org>
Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Cc: 'chugalug@listserv.highertech.net' <chugalug@listserv.highertech.net>
Subject: Re: [SQL] perl and postgres. . .
Date: Wed, 21 Apr 1999 15:10:28 -0400 (EDT)
Message-ID: <Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com> (raw)
In-Reply-To: <01BE8BEC.76C02840.jt-kirkpatrick@mpsllc.com>

On Wed, 21 Apr 1999, JT Kirkpatrick wrote:

> I'm trying in perl to get a maximum value from a field in a postgres table:
> $query="select max(userseq) from dataentry;";
> $result=$conn->exec("$query");
> 
> and then capture that value in a scalar variable:
> 	$userseq=($result);
> 
> but it's not working.  The field userseq is int4 if that matters to you. 
>  if I can capture that value in a variable then I can use it in an update 
> query for that particular record.  Can anyone enlighten me??

You can't get row information from a query that way.  You need to use 
$result->fetchrow to get the actual data out of your query (it returns 
Null if there are no more rows to fetch from). You could do something like:

@q_row = $result->fetchrow;
$userseq = $q_row[0];

To get that information.


Brett W. McCoy           
                                         http://www.lan2wan.com/~bmccoy
-----------------------------------------------------------------------
Self Test for Paranoia:
	You know you have it when you can't think of anything that's
your own fault.




view thread (2+ messages)

Message-ID: <Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com>
Permalink:  ../Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com/
Also on:    postgresql.org/message-id/Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bmccoy@lan2wan.com, jt-kirkpatrick@mpsllc.com, pgsql-interfaces@hub.org, pgsql-sql@hub.org, chugalug@listserv.highertech.net
  Subject: Re: [SQL] perl and postgres. . .
  In-Reply-To: <Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com>
  References: <01BE8BEC.76C02840.jt-kirkpatrick@mpsllc.com> <Pine.BSI.3.91.990421150243.10411G-100000@access1.lan2wan.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox