no OID field in OLD or NEW records inside trigger functions?

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема no OID field in OLD or NEW records inside trigger functions?
Дата
Msg-id 20010412183707.A3943@apartia.ch
обсуждение исходный текст
Список pgsql-general
This trigger function attempts to copy a record into an archive table
before deletion:

    create trigger archive_adresse before update or delete on adresse
        for each row execute procedure archive_row();

    create function archive_row() returns opaque as '
    DECLARE
        tname text;
        rec RECORD;
    BEGIN
        tname := TG_RELNAME || ''_archive'';
        INSERT INTO tname SELECT * from TG_RELNAME WHERE oid = OLD.oid;
        RETURN OLD;
    END;
    ' language 'plpgsql';

But I get:
psql:archive.sql:25: ERROR:  record old has no field oid

What would the best way to have a generic trigger function copy an
entire NEW or OLD row to an archive (given that the archive table is
always named <table>_archive)?

Thanks in advance,

--
"2c98611832ea3f6f5fdda95d3704fbb8" (a truly random sig)

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

Предыдущее
От: Alessio Bragadini
Дата:
Сообщение: Re: to_char(now(), 'YYYY') and time zones
Следующее
От: "Howard Williams"
Дата:
Сообщение: