Re: Insert rule and seqences

Поиск
Список
Период
Сортировка
От Bo Lorentsen
Тема Re: Insert rule and seqences
Дата
Msg-id 3B948D76.53D1744A@netgroup.dk
обсуждение исходный текст
Ответ на Insert rule and seqences  (Bo Lorentsen <bl@netgroup.dk>)
Список pgsql-novice
Jochem van Dieten wrote:

> I wouldn't use a RULE but a TRIGGER. Something like the one below
> (please check syntax ;) ).

Thanks, this works perfect for me now.

Is it correct that this is not possible to do when using pure "language 'sql'"
? As this language type can't refere to the "new" attribute.

> CREATE TRIGGER tr_insert_on_a AFTER INSERT OR UPDATE ON A
> FOR EACH ROW EXECUTE PROCEDURE fn_insert_on_a();
>
> CREATE function fn_insert_on_a() RETURNS OPAQUE AS '
>      BEGIN
>          INSERT INTO B name, a_ref VALUES(NEW.name, NEW.id);
>      END;
> ' LANGUAGE 'plpgsql';

You only needed the "RETURN new;" line and this was perfect, thanks.

/BL


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

Предыдущее
От: Bo Lorentsen
Дата:
Сообщение: Re: pl/pgsql recursion/arrays (fwd)
Следующее
От: Jason Tan
Дата:
Сообщение: Re: pl/pgsql recursion/arrays (fwd)