Re: best way to swap two records (computer details)

Поиск
Список
Период
Сортировка
От PFC
Тема Re: best way to swap two records (computer details)
Дата
Msg-id op.snumxjkpth1vuj@localhost
обсуждение исходный текст
Ответ на best way to swap two records (computer details)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Ответы Re: best way to swap two records (computer details)  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
Список pgsql-sql
> My question is what's the best way to swap settings between the two
> computer records and swap any software installed?  Ideally I'd like it
> in the form of a function where I can pass the two p_id's and return a
> boolean reflecting success (true) or fail (false).

I'd say something like that (generic table names) :

If you're confident :
UPDATE stuff SET owner = (CASE IF owner='A' THEN 'B' ELSE 'A' END) WHERE  
owner IN ('A','B')

If you're paranoid :
UPDATE stuff SET owner = (CASE IF owner='A' THEN 'B' ELSE IF owner='B'  
THEN 'A' ELSE owner END) WHERE owner IN ('A','B')



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

Предыдущее
От: lucas@presserv.org
Дата:
Сообщение: Trigger with parameters
Следующее
От: Leon Stringer
Дата:
Сообщение: Re: Consecutive row count query