| From: | Louis-David Mitterrand <vindex(at)apartia(dot)ch> |
|---|---|
| To: | pgsql-general(at)postgresql(dot)org |
| Subject: | no OID field in OLD or NEW records inside trigger functions? |
| Date: | 2001-04-12 16:37:07 |
| Message-ID: | 20010412183707.A3943@apartia.ch |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Howard Williams | 2001-04-12 18:19:11 | |
| Previous Message | Michael Ansley | 2001-04-12 14:27:38 | RE: to_char(now(), 'YYYY') and time zones |