From: | Tariq Muhammad <tmuhamma(at)mail(dot)libertyrms(dot)com> |
---|---|
To: | pgsql-admin(at)postgresql(dot)org |
Subject: | Please help |
Date: | 2002-04-10 15:49:06 |
Message-ID: | Pine.LNX.4.21.0204101147230.21405-100000@genesis.int.libertyrms.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi Folks
I am trying to write a function that should archive old values to an
archiving table before update on the orignal table but it inserts both old
and new values to the archiving table here is the code:
CREATE FUNCTION fn_archive_01() RETURNS OPAQUE AS '
BEGIN
/* TG_OP is the function (UPDATE, DELETE, SELECT) */
INSERT INTO customer_archive
VALUES
(OLD.id, OLD.name,current_user,now(),TG_OP);
IF TG_OP = ''UPDATE''
THEN
RETURN NEW;
END IF;
RETURN OLD;
END;
' LANGUAGE 'plpgsql';
CREATE TRIGGER tr_customer_archive_del BEFORE DELETE
ON customer FOR EACH ROW
EXECUTE PROCEDURE fn_archive_01();
Thanks for your help
Tariq
From | Date | Subject | |
---|---|---|---|
Next Message | Naomi Walker | 2002-04-10 16:27:41 | Re: performance "tests" |
Previous Message | Tom Lane | 2002-04-10 15:37:03 | Re: performance "tests" |