no OID field in OLD or NEW records inside trigger functions? - Mailing list pgsql-general

From Louis-David Mitterrand
Subject no OID field in OLD or NEW records inside trigger functions?
Date
Msg-id 20010412183707.A3943@apartia.ch
Whole thread Raw
List 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 by date:

Previous
From: Alessio Bragadini
Date:
Subject: Re: to_char(now(), 'YYYY') and time zones
Next
From: "Howard Williams"
Date:
Subject: