Re: Java and Currval

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: Java and Currval
Дата
Msg-id 20050502164639.GA51265@winnie.fuhr.org
обсуждение исходный текст
Ответ на Java and Currval  ("Sam Adams" <samadams@myfastmail.com>)
Список 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/


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Sam Adams"
Дата:
Сообщение: Java and Currval
Следующее
От: Volkan YAZICI
Дата:
Сообщение: Re: Java and Currval