Re: triggers vs. 'NEW in non-rule query' -- SOLVED?

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: triggers vs. 'NEW in non-rule query' -- SOLVED?
Дата
Msg-id 200103080654.BAA13596@jupiter.jw.home
обсуждение исходный текст
Ответ на triggers vs. 'NEW in non-rule query' -- SOLVED?  (will trillich <will@serensoft.com>)
Ответы Re: triggers vs. 'NEW in non-rule query' -- SOLVED?
Список pgsql-general
will trillich wrote:
>
> i THINK i've got it! MWAAH HA HA...
>

    Congrats

> i follow the example from the postgresql-doc/html/user/c4*40.html
> document and define a function to be called via TRIGGER...
>
>    CREATE FUNCTION easy() RETURNS OPAQUE AS '
>    DECLARE
>         x CHAR(1) := NEW.somefield FROM 1 FOR 1;
>    BEGIN
>         -- whatever, yada yada, bada bing bada boom
>         RETURN NEW;
>    END;
>    ' language 'plpgsql';

    Grmpf - exactly that's missing in the "#option dump" output -
    the   calculation   of   default    values    for    variable
    initialization.  I  was looking at your log-snippent over and
    over again and couldn't see it :-)

>
> and this results in "ERROR: use of NEW in non-rule procedure"
> when actually called via TRIGGER. i change it instead to
>
>    CREATE FUNCTION easy() RETURNS OPAQUE AS '
>    DECLARE
>         x CHAR(1); -- no := assignment here
>    BEGIN
>         x := NEW.somefield FROM 1 FOR 1;
>         -- whatever, yada yada, bada bing bada boom
>         RETURN NEW;
>    END;
>    ' language 'plpgsql';
>
> and suddenly all is right with the world. so i can't refer to the
> NEW (or probably OLD) pseudotables WITHIN THE DECLARE section.
> apparently.
>
> Q: is this a bug? is this a feature?

    A missing feature, and something  that  should  be  on  7.2's
    TODO.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: length of insert stmt?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: triggers vs. 'NEW in non-rule query' -- SOLVED?