Re: currval()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux