is it possible to do an update with a nested select that references the outer update ?

Поиск
Список
Период
Сортировка
От Jonathan Vanasco
Тема is it possible to do an update with a nested select that references the outer update ?
Дата
Msg-id 1DDC8F20-7318-4188-86E9-8221FE2502AA@2xlp.com
обсуждение исходный текст
Ответы Re: is it possible to do an update with a nested select that references the outer update ?  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Список pgsql-general
A typo in a webapp left ~150 records damaged overnight

I was hoping to automate this, but may just use regex to make update
statements for this

basically , i have this situation:

table a ( main record )
    id , id_field , fullname

table b ( extended profiles )
    id_field , last_name , first_name, middle_name , age , etc

id_field on table a was left null due to a typo with the orm

i've tried many variations to automate it, none seem to work

i think this attempt most clearly expresses what I was trying to do

    UPDATE table_a a set id_field = ( SELECT id_field FROM table_b b
WHERE a.first_name || ' ' || b.last_name = a.fullname ) WHERE id_field
IS NULL ;

I'd be greatful if anyone has a pointer

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: attempted to lock invisible tuple - PG 8.4.1
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: attempted to lock invisible tuple - PG 8.4.1