From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Sam Adams <samadams(at)myfastmail(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Java and Currval |
Date: | 2005-05-02 16:46:39 |
Message-ID: | 20050502164639.GA51265@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, May 02, 2005 at 05:30:12PM +0100, Sam Adams wrote:
>
> I'm having trouble getting the currval function to work from a Java
> program (or from Postgres at all). I want to get the value of addressid
> in the table taddress. The best I seem to be able to come up with is
> 'SELECT currval(taddress.addressid)'.
The argument to currval() is a quoted sequence name, so you probably
need something like this:
SELECT currval('taddress_addressid_seq');
In PostgreSQL 8.0 you can use pg_get_serial_sequence() to get the
sequence name from the table and column names:
SELECT currval(pg_get_serial_sequence('taddress', 'addressid'));
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
From | Date | Subject | |
---|---|---|---|
Next Message | Volkan YAZICI | 2005-05-02 16:49:12 | Re: Java and Currval |
Previous Message | Sam Adams | 2005-05-02 16:30:12 | Java and Currval |