Skip site navigation (1) Skip section navigation (2)

Re: [SQL] perl and postgres. . .

From: "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>
Cc: "'pgsql-interfaces(at)hub(dot)org'" <pgsql-interfaces(at)hub(dot)org>, "'pgsql-sql(at)hub(dot)org'" <pgsql-sql(at)hub(dot)org>, "'chugalug(at)listserv(dot)highertech(dot)net'" <chugalug(at)listserv(dot)highertech(dot)net>
Subject: Re: [SQL] perl and postgres. . .
Date: 1999-04-21 19:10:28
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfacespgsql-sql
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           
Self Test for Paranoia:
	You know you have it when you can't think of anything that's
your own fault.

In response to

pgsql-interfaces by date

Next:From: Gene Selkov, Jr.Date: 1999-04-21 19:36:08
Subject: Re: [SQL] perl and postgres. . .
Previous:From: Brett W. McCoyDate: 1999-04-21 18:57:13
Subject: Re: [INTERFACES] Possible error in libpg++ interface, date[time] fields.

pgsql-sql by date

Next:From: novikovDate: 1999-04-22 10:19:03
Subject: default in ALTER
Previous:From: JT KirkpatrickDate: 1999-04-21 18:34:18
Subject: convert text to number or number to text

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group