pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julius Tuskenis <julius@nsoft.lt>
To: pgsql-admin@postgresql.org
Subject: Re: currval()
Date: Wed, 21 Sep 2011 11:41:11 +0300
Message-ID: <4E79A327.5050902@nsoft.lt> (raw)
In-Reply-To: <93361C67E4EE844A80935863A4FF4B6C051150A2@Exch2010MB-2.univ.dir.wwu.edu>
References: <93361C67E4EE844A80935863A4FF4B6C051150A2@Exch2010MB-2.univ.dir.wwu.edu>

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

view thread (4+ messages)

Message-ID: <4E79A327.5050902@nsoft.lt>
Permalink:  ../4E79A327.5050902@nsoft.lt/
Also on:    postgresql.org/message-id/4E79A327.5050902@nsoft.lt

 · 

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-admin@postgresql.org
  Cc: julius@nsoft.lt
  Subject: Re: currval()
  In-Reply-To: <4E79A327.5050902@nsoft.lt>

* 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