Re: basic trigger using OLD not working?

Поиск
Список
Период
Сортировка
От Ian Harding
Тема Re: basic trigger using OLD not working?
Дата
Msg-id s21ec642.011@MAIL.TPCHD.ORG
обсуждение исходный текст
Ответ на basic trigger using OLD not working?  (Rick Casey <rick.casey@colorado.edu>)
Ответы Re: basic trigger using OLD not working?  (Rick.Casey@colorado.edu)
Список pgsql-general
I think you have created a statement level trigger (If they existed in
7.4.7...)  by not including FOR EACH ROW in your create statement.  In
statement level triggers, there is no OLD or NEW.

>>> Rick Casey <rick.casey@colorado.edu> 02/24/05 1:22 PM >>>
Hello all,

I am trying to a simple thing: create a log history of deletes, and
updates; but which I am having trouble getting to work in PG 7.4.7
(under Debian Linux 2.6.8).

I have reduced my code to the following trivial case:

Here is the code that creates the delete trigger:
create trigger PEDIGREES_hist_del_trig
AFTER DELETE
on PEDIGREES
EXECUTE PROCEDURE logPedigreesDel();


Here is the trigger code: (famindid is an integer field in the Pedigrees

table):

CREATE OR REPLACE FUNCTION logPedigreesDel() RETURNS TRIGGER AS '
DECLARE
    test integer;
begin
    test := OLD.famindid;
    RAISE EXCEPTION ''OLD.famindid = '', test;
    return OLD;
end;
' LANGUAGE plpgsql;


Here is the error message returned:
psql:testphdtrig.sql:1: ERROR:  record "old" is not assigned yet
DETAIL:  The tuple structure of a not-yet-assigned record is
indeterminate.
CONTEXT:  PL/pgSQL function "logpedigreesdel" line 4 at assignment

Would *really appreciate* any suggestions! This could help us decide
whether to PostGres for a major project...

thanks --rick

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend


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

Предыдущее
От: Christoph Pingel
Дата:
Сообщение: psycopg can't find postgres process
Следующее
От: Si Chen
Дата:
Сообщение: postgresql 8.0 advantages