From: Joepie Platteau <Joepie.Platteau@kulak.ac.be>
To: pgsql-admin@postgresql.org
Subject: Trigger set to backup to other table NOT FUNCTIONING...
Date: Mon, 13 Sep 2004 12:05:06 +0200
Message-ID: <414570D2.9090405@kulak.ac.be> (raw)
Hi,
I have a problem with my trigger... :
my tables :
CREATE TABLE public."T-Alumni" (
"Id_Persoon" int8 DEFAULT nextval('"T-Alumni_Id_Persoon_seq"'::text) NOT
NULL,
"SteunendLid" bool,
"Betaald" bool,
"Stamnr" int4,
"Alumninr" int4,
"Acjaar" varchar(50),
"Studiejaar" varchar(50),
CONSTRAINT "T-Alumni_pkey" PRIMARY KEY ("Id_Persoon")
) WITH OIDS;
CREATE TABLE public."T-Alumni-backup" (
"Id_Persoon" int8 NOT NULL,
"SteunendLid" bool,
"Betaald" bool,
"Stamnr" int4,
"Alumninr" int4,
"Acjaar" varchar(50),
"Studiejaar" varchar(50)
) WITH OIDS;
i have a table (T-Alumni) and BEFORE a record changes or is being
deleted, I want to copy this record to a UNDO_table (T-Alumni-backup).
I tried like this :
CREATE FUNCTION public.f100() RETURNS trigger AS '
BEGIN
INSERT INTO "T-Alumni-backup" VALUES (NEW.Id_Persoon, NEW.SteunendLid,
NEW.Betaald, NEW.Stamnr, NEW.Alumninr, NEW.Acjaar, NEW.Studiejaar);
RETURN NEW;
END;
' LANGUAGE 'plpgsql' VOLATILE;
CREATE TRIGGER t100t BEFORE DELETE OR UPDATE ON public."T-Alumni" FOR
EACH ROW EXECUTE PROCEDURE f100();
I get this error :
Record "new" has no field "id_persoon" (#7)
Also I want to have the name of the person who deleted or changed the
record in my BackUp (undo) table...
Can someone tell me how to solve this problem?
Thanx!
Joepie.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: Joepie.Platteau@kulak.ac.be
Subject: Re: Trigger set to backup to other table NOT FUNCTIONING...
In-Reply-To: <414570D2.9090405@kulak.ac.be>
References: <414570D2.9090405@kulak.ac.be>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox