From: Steve Crawford <scrawford@pinpointresearch.com>
To: Marc Fromm <Marc.Fromm@wwu.edu>
Cc: pgsql-admin@postgresql.org Admin <pgsql-admin@postgresql.org>
Subject: Re: currval()
Date: Tue, 20 Sep 2011 16:54:37 -0700
Message-ID: <4E7927BD.50404@pinpointresearch.com> (raw)
In-Reply-To: <93361C67E4EE844A80935863A4FF4B6C05115121@Exch2010MB-2.univ.dir.wwu.edu>
References: <93361C67E4EE844A80935863A4FF4B6C051150A2@Exch2010MB-2.univ.dir.wwu.edu>
<4E791940.1040903@pinpointresearch.com>
<93361C67E4EE844A80935863A4FF4B6C05115121@Exch2010MB-2.univ.dir.wwu.edu>
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
necessary.)
> 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.
Cheers,
Steve
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 using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: scrawford@pinpointresearch.com, Marc.Fromm@wwu.edu
Subject: Re: currval()
In-Reply-To: <4E7927BD.50404@pinpointresearch.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