Re: How to lock a table for update and make other connections to wait on it

Поиск
Список
Период
Сортировка
От Christophe Pettus
Тема Re: How to lock a table for update and make other connections to wait on it
Дата
Msg-id BE307F8C-E958-4DFF-9695-BB73D3573F47@thebuild.com
обсуждение исходный текст
Ответ на How to lock a table for update and make other connections to wait on it  ("Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)" <vamsredd@cisco.com>)
Список psycopg
On Jul 9, 2015, at 9:31 AM, Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco)
<vamsredd@cisco.com>wrote: 

> 1.       Insert a row to a table , using cursor.execute()
> 2.       To fetch the row id of the above inserted data, we are using cursor.execute() to execute a sql command which
fetchesthe max ‘id’ from the table (id is a column in the table which gets incremented on each insert) 

Don't do it that way.  Use the RETURNING clause on INSERT to get the inserted value.
--
-- Christophe Pettus
   xof@thebuild.com



В списке psycopg по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: Re: How to lock a table for update and make other connections to wait on it
Следующее
От: "Karsten Hilbert"
Дата:
Сообщение: Re: How to lock a table for update and make other connections to wait on it