Re: Java and Currval

From: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Java and Currval
Date: 2005-05-02 16:49:12
Message-ID: 7104a737050502094915b74816@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

On 5/2/05, Sam Adams <samadams(at)myfastmail(dot)com> 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)'. However this gives me the error
> 'ERROR: relation "1" does not exist' or whatever the number should be.
> I've tried lots of variations but can't seem to work it out. What am I
> doing wrong?

You should use the sequence as parameter to currval(), like:

=> \d products
Table "public.products"
-[ RECORD 1 ]----------------------------------------------------------
Column | proid
Type | integer
Modifiers | not null default nextval('public.products_proid_seq'::text)
=> SELECT currval(products.proid);
ERROR: relation "1" does not exist
=> SELECT currval('public.products_proid_seq'::text);
nextval
---------
7
(1 row)

Regards.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bruno Wolff III 2005-05-02 17:41:11 Re: Java and Currval
Previous Message Michael Fuhr 2005-05-02 16:46:39 Re: Java and Currval