Re: Update problem.

Поиск
Список
Период
Сортировка
От Andrew Sullivan
Тема Re: Update problem.
Дата
Msg-id 20070402151726.GA30052@phlogiston.dyndns.org
обсуждение исходный текст
Ответ на Update problem.  ("Shavonne Marietta Wijesinghe" <shavonne.marietta@studioform.it>)
Список pgsql-sql
On Mon, Apr 02, 2007 at 04:52:46PM +0200, Shavonne Marietta Wijesinghe wrote:
> At a surtain point i need to replace a record with another
> 
> For example i have inserted 4 records. (1, 2 ,  3 , 4) I need to
> replace all the values from the record 4 to the record 2 but
> keeping the n_gen serial key. And then delete the record 4. So that
> the next record i insert will take the n_gen 4

If I understand you correclty, you can do an UPDATE to record 4 to
record 2, then do a setval() on the sequence.  The setval() is
tricky, though, because you have the problem that other connections
could be using it.  I'd lock the table in question while you did all
this.

A

-- 
Andrew Sullivan  | ajs@crankycanuck.ca
Unfortunately reformatting the Internet is a little more painful 
than reformatting your hard drive when it gets out of whack.    --Scott Morris


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

Предыдущее
От: "Shavonne Marietta Wijesinghe"
Дата:
Сообщение: Update problem.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Calling void functions