Re: currval() - Mailing list pgsql-admin

From Julius Tuskenis
Subject Re: currval()
Date
Msg-id 4E79A327.5050902@nsoft.lt
Whole thread Raw
In response to currval()  (Marc Fromm <Marc.Fromm@wwu.edu>)
List pgsql-admin
Hello, Mark

On 2011.09.21 01:00, Marc Fromm wrote:

The field name is ‘id’ and it is a primary key.

...

                $sql .= "SELECT currval('id');";

Marc

You should pass sequence name to currval (not field name like you do now). If you use pgAdmin sequence name is easily found looking at fields definition near the DEFAULT.

example:

ALTER TABLE b_preke ADD COLUMN prek_id integer;
ALTER TABLE b_preke ALTER COLUMN prek_id SET NOT NULL;
ALTER TABLE b_preke ALTER COLUMN prek_id SET DEFAULT nextval('b_preke_prek_id_seq'::regclass);

the field is prek_id and the sequence is b_preke_prek_id_seq
-- 
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050

pgsql-admin by date:

Previous
From: Rural Hunter
Date:
Subject: Re: Warm standby terminate itself?
Next
From: Daniel Vázquez
Date:
Subject: Unaccent contrib module for PostgreSQL 8.4