Hi, On 5/2/05, Sam Adams <[EMAIL PROTECTED]> 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. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster