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

Re: currval()

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Marc Fromm <Marc(dot)Fromm(at)wwu(dot)edu>
Cc: "pgsql-admin(at)postgresql(dot)org Admin" <pgsql-admin(at)postgresql(dot)org>
Subject: Re: currval()
Date: 2011-09-20 23:54:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
On 09/20/2011 04:06 PM, Marc Fromm wrote:
> My postgres version is 8.1. Last I heard RETURNING id started in 8.2.
I'd advise upgrading. 8.1 is no-longer supported (end-of-life was last 
November) and 8.2 has an end-of-life date in just a couple months. 
You'll get security and bug fixes, performance benefits and, of course, 
those cool new features you need. :)

(No security fixes is often the issue that gets management attention if 

> Is not my semicolon before the select statement make it two sequential 
> staements?
> I don't get an sql error when it is executed.

Well, it is technically legal (and why SQL injection can work). Looks 
like you are using PHP and PHP says that if you bundle statements 
together they will be executed as a transaction.

Perhaps it's personal preference, but combining statements like that is 
difficult to read and I suspect will make bugs hard to find. And 
although I can't find it documented, it appears that the return value is 
only from the final statement. I shy away from undocumented behaviour 
and I'd rather be able to check the result of each statement.

> I did learn from another reply that my select statement was wrong. I 
> needed to SELECT currval('jobs_id_seq') not the field name, which I 
> was doing.

Yes, this is probably the real root of your problem. I did not notice 
that since I didn't have the table definition in front of me.


In response to

pgsql-admin by date

Next:From: Rural HunterDate: 2011-09-21 01:23:59
Subject: Re: Warm standby terminate itself?
Previous:From: Steve CrawfordDate: 2011-09-20 22:52:48
Subject: Re: currval()

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