X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1578D5331D for ; Mon, 2 May 2005 13:49:18 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 30599-03 for ; Mon, 2 May 2005 16:49:13 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.203]) by svr1.postgresql.org (Postfix) with ESMTP id 5101C5392D for ; Mon, 2 May 2005 13:49:12 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1586410wri for ; Mon, 02 May 2005 09:49:13 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=HDMJgRbsZuv/jVY4PlePx2m7emA6Qp3AU2bNKwqaCHlu2HY6mYNhWNK/M87MQ//iDTY89Sv8DARXp96sNYXWXDed4Lc+3760Sc8bv3EhNlAE8eiwa1YMTRCutkvAM3fKOzmddwAHoicxLzNta9Ocn1BoSjOYNJBWQLu3Zf2eUYE= Received: by 10.54.122.16 with SMTP id u16mr655244wrc; Mon, 02 May 2005 09:49:13 -0700 (PDT) Received: by 10.54.30.31 with HTTP; Mon, 2 May 2005 09:49:12 -0700 (PDT) Message-ID: <7104a737050502094915b74816@mail.gmail.com> Date: Mon, 2 May 2005 19:49:12 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: pgsql-sql@postgresql.org Subject: Re: Java and Currval In-Reply-To: <1115051412.14477.233176976@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <1115051412.14477.233176976@webmail.messagingengine.com> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/18 X-Sequence-Number: 21331 Hi, On 5/2/05, 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)'. 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: =3D> \d products Table "public.products" -[ RECORD 1 ]---------------------------------------------------------- Column | proid Type | integer Modifiers | not null default nextval('public.products_proid_seq'::text) =3D> SELECT currval(products.proid); ERROR: relation "1" does not exist =3D> SELECT currval('public.products_proid_seq'::text); nextval --------- 7 (1 row) Regards.