Re: [GENERAL] serial autoincrement and related table

2004-05-20 Thread Marco Colombo
On Mon, 17 May 2004, Milos Prudek wrote: > > > Actually, if you declared idmember as SERIAL PRIMARY KEY, you could > > just do: > > I can't do that. idmember is a SERIAL PRIMARY KEY for members. Each > member can have many messages (msg table) with the same idmember column > value. See my or

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
> Actually, if you declared idmember as SERIAL PRIMARY KEY, you could > just do: I can't do that. idmember is a SERIAL PRIMARY KEY for members. Each member can have many messages (msg table) with the same idmember column value. See my original post. -- Milos Prudek ---(en

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
Alternatively, you could rewrite this query: "INSERT INO msg (idmember,txt) VALUES (currval('members_idmember_seq'), %s);" Cool. You helped me demolish 3 lines of code with no compromise in legibility. -- Milos Prudek ---(end of broadcast)--- TIP 5

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Richard Huxton
Milos Prudek wrote: I have a serial autoincrement column called "idmember" in my main table (members). This serial column is a key to a second table. A row in "members" table corresponds to many rows in the second table. My question is: is this the best practice? Here's an example in Python: con

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
> 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 I do omit it. > DEFAULT nextval('members_idmember_seq') defined on the idmember

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Paul Thomas
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

[GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
I have a serial autoincrement column called "idmember" in my main table (members). This serial column is a key to a second table. A row in "members" table corresponds to many rows in the second table. What is the best way to discover current "idmember" value if I create a few rows in the second