Re: serial autoincrement and related table - Mailing list pgsql-general

From Paul Thomas
Subject Re: serial autoincrement and related table
Date
Msg-id 20040517123133.A13721@bacon
Whole thread Raw
In response to serial autoincrement and related table  (Milos Prudek <prudek@bvx.cz>)
Responses Re: serial autoincrement and related table
List 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   |
+------------------------------+---------------------------------------------+

pgsql-general by date:

Previous
From: Milos Prudek
Date:
Subject: serial autoincrement and related table
Next
From: Milos Prudek
Date:
Subject: Re: serial autoincrement and related table