From: | will trillich <will(at)serensoft(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: UPDATE keyword |
Date: | 2001-06-02 09:11:12 |
Message-ID: | 20010602041112.C10951@serensoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Fri, May 25, 2001 at 04:16:00PM -0700, Ian Harding wrote:
> Well, I am making progress in rewriting my MSSQL Server T-SQL triggers and stored procedures in Pl/Tcl. However, I have run into a bit of an issue and I wonder if anyone knows the best way to address it...
>
> In T-SQL triggers, you can use the UPDATE keyword in conditional expressions as in
>
> IF UPDATE(myfield)
> BEGIN
> do something
> END
>
> It detects the update of the field. I have been comparing
> $NEW(myfield) and $OLD(myfield) which works ok, except where I
> used the UPDATE() test as a crutch. I sometimes do an update
> like
>
> UPDATE mytable SET myfield = myfield WHERE...
>
> to fire an update trigger, and executing only the code in that trigger surrounded by UPDATE(myfield).
>
> Is there an easy way to duplicate this, or should I work around it?
how about
create view
relationname
as select * from _real_relation_name_;
create rule
on update to relationname
do instead (
update _real_relation_name_
set fld=new.fld,
col=new.col,
modified=current_timestamp,
differencefield=old.something-new.something,
whatever=some_function()
;
insert into _some_tracking_relation_
( field, list, here )
values
( ... )
);
check out the manuals for 'create rule'. very handy stuff.
--
#95: We are waking up and linking to each other. We are watching. But
we are not waiting. -- www.cluetrain.com
will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
From | Date | Subject | |
---|---|---|---|
Next Message | will trillich | 2001-06-02 09:17:28 | Re: pl-perl setup? |
Previous Message | will trillich | 2001-06-02 09:06:27 | Re: How to access arrays from DBD::Pg? |