pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Volkan YAZICI <volkan.yazici@gmail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Java and Currval
Date: Mon, 2 May 2005 19:49:12 +0300
Message-ID: <7104a737050502094915b74816@mail.gmail.com> (raw)
In-Reply-To: <1115051412.14477.233176976@webmail.messagingengine.com>
References: <1115051412.14477.233176976@webmail.messagingengine.com>

Hi,

On 5/2/05, Sam Adams <samadams@myfastmail.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.



view thread (4+ messages)  latest in thread

Message-ID: <7104a737050502094915b74816@mail.gmail.com>
Permalink:  ../7104a737050502094915b74816@mail.gmail.com/
Also on:    postgresql.org/message-id/7104a737050502094915b74816@mail.gmail.com

 · 

reply

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-sql@postgresql.org
  Cc: volkan.yazici@gmail.com
  Subject: Re: Java and Currval
  In-Reply-To: <7104a737050502094915b74816@mail.gmail.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