Re: currval()

From: Julius Tuskenis <julius(at)nsoft(dot)lt>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: currval()
Date: 2011-09-21 08:41:11
Message-ID: 4E79A327.5050902@nsoft.lt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

  • currval() at 2011-09-20 22:00:57 from Marc Fromm

Browse pgsql-admin by date

  From Date Subject
Next Message c k 2011-09-21 10:08:11 Date time value error in Ms Access using pass through queries
Previous Message Rural Hunter 2011-09-21 01:23:59 Re: Warm standby terminate itself?