From: | "amy cheng" <amycq(at)hotmail(dot)com> |
---|---|
To: | pgsql-general(at)postgreSQL(dot)org |
Subject: | do delete/insert instead of update if name changes |
Date: | 1999-08-31 09:01:14 |
Message-ID: | 19990831160114.25350.qmail@hotmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
hi, all experts there,
I'm studying the example in postgresql-6.5.1/src/pl/plpgsql/test.
I do not understand why we need "do delete/insert instead of update if name
changes". Is it ONLY for the test, or, there is some
reason for doing that in practical use?
I cut/paste part of it below.
Thanks !!!!!
amy
########################################
-- ************************************************************
-- * BEFORE UPDATE on PHone
-- * - do delete/insert instead of update if name changes
-- ************************************************************
create function tg_phone_bu() returns opaque as '
begin
if new.slotname != old.slotname then
delete from PHone where slotname = old.slotname;
insert into PHone (
slotname,
comment,
slotlink
) values (
new.slotname,
new.comment,
new.slotlink
);
return null;
end if;
return new;
end;
' language 'plpgsql';
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
From | Date | Subject | |
---|---|---|---|
Next Message | Pablo Sentis | 1999-08-31 10:09:19 | Referential integrity |
Previous Message | amy cheng | 1999-08-31 06:35:06 | Re: [GENERAL] Referential integrity |