Re: [GENERAL] insert with select as value

2004-06-23 Thread Milos Prudek
ething like the following to take advantage of the index: coallesce((SELECT idthread FROM table WHERE idsection = 'CZE' ORDER BY idthread DESC, idsection DESC LIMT 1))+1 That's interesting and valuable, thank you very much. -- Milos Prudek _ Most websites are confused c

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. -- M

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)---

Re: [GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
ncrement fields in > PostgreSQL - they are SEQUENCES. I know. So, it's the best or reasonable practice(TM), isn't it? -- Milos Prudek ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[GENERAL] serial autoincrement and related table

2004-05-17 Thread Milos Prudek
t; c.execute(Cmd, Data) Cmd = "SELECT currval('members_idmember_seq') FROM members LIMIT 1;" c.execute(Cmd) idmember = c.fetchone()[0] Cmd = "INSERT INTO msg (idmember,txt) VALUES (%s,%s);" c.execute(Cmd,(idmember,TxtData) conn.commit()