Re: Instead trigger on a view to update base tables ?

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Instead trigger on a view to update base tables ?
Дата
Msg-id CAKFQuwZQzWZkGZ0=1kFVPjG=n4JEb5KD4a9chyXsFndFCYA2Dw@mail.gmail.com
обсуждение исходный текст
Ответ на Instead trigger on a view to update base tables ?  ("Day, David" <dday@redcom.com>)
Список pgsql-general
On Tue, Aug 7, 2018 at 12:09 PM, Day, David <dday@redcom.com> wrote:
EXECUTE format(' UPDATE admin.user SET (%I) = ( SELECT %I FROM $1 )  WHERE id = $2)', USER_SETTING, USER_SETTING )
                    USING NEW,  NEW.id;

When this executes my exception handler generates "err syntax error at or near \"$1\"

The value after FROM must be an identifier and so cannot be parameterized.  You have to use "%I" for that dynamic element as well - only $2 (which becomes $1) is valid to parameterize (though you could just do "%L" and drop the USING clause on the EXECUTE...)

David J.

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

Предыдущее
От: "Day, David"
Дата:
Сообщение: Instead trigger on a view to update base tables ?
Следующее
От: Marcelo Lacerda
Дата:
Сообщение: check_function_bodies not doing much