From: | Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk> |
---|---|
To: | Milos Prudek <prudek(at)bvx(dot)cz> |
Cc: | "pgsql-general (at) postgresql (dot) org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: serial autoincrement and related table |
Date: | 2004-05-17 11:31:33 |
Message-ID: | 20040517123133.A13721@bacon |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 17/05/2004 11:24 Milos Prudek wrote:
> Cmd = "INSERT INTO members ... VALUES (...);"
If you want PostgreSQL to populate your idmember field with the next value
from the sequence, you need to specify the keyword DEFAULT as its value or
omit it from the INSERT list of coulumns (this assumes you have DEFAULT
nextval('members_idmember_seq') defined on the idmember column).
> Cmd = "SELECT currval('members_idmember_seq') FROM members LIMIT 1;"
Should be :
Cmd = "SELECT currval('members_idmember_seq');"
Remember that there's no such thing as auto-increment fields in PostgreSQL
- they are SEQUENCES.
--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for
Business |
| Computer Consultants |
http://www.thomas-micro-systems-ltd.co.uk |
+------------------------------+---------------------------------------------+
From | Date | Subject | |
---|---|---|---|
Next Message | Milos Prudek | 2004-05-17 11:52:55 | Re: serial autoincrement and related table |
Previous Message | Milos Prudek | 2004-05-17 10:24:38 | serial autoincrement and related table |