Re: [INTERFACES] locking on database updates

Поиск
Список
Период
Сортировка
От Douglas Thomson
Тема Re: [INTERFACES] locking on database updates
Дата
Msg-id 199912080434.PAA31285@mugca.cc.monash.edu.au
обсуждение исходный текст
Ответ на RE: [INTERFACES] locking on database updates  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Список pgsql-interfaces
Gary Stainburn writes:
> I agree that using a type 'serial' will give me what I want
> regarding the key field for my table, and gets round the problem
> of concurrent users trying to create records with the same number.
>
> The problem is that this does not actually give me the number that
> was just created.  As there is no guarantee that the other fields in
> the table are unique (hence the serial field in the first place) I cannot
> simply do a select to retrieve it.
>
> Has anyone any ideas?

For what it is worth, I saved the OID returned by the INSERT (see
PQoidStatus - the details depend on what interface language you use),
and then selected the row I had just inserted using:
    SELECT id FROM name_map WHERE oid=12345

Doug.

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

Предыдущее
От: Joseph Shraibman
Дата:
Сообщение: sql question
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [INTERFACES] sql question