Re: [HACKERS] [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-23 Thread Aasmund Midttun Godal
Yes, I agree perfectly... I never thought of that! I would really like it if some more info was added to the docs regarding info on rules and triggers. The section on update rules is quite good, but some more would never hurt. One point in the trigger vs rules section which at least to me is ve

Re: [HACKERS] [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-23 Thread Joel Burton
On Sat, 20 Oct 2001, Aasmund Midttun Godal wrote: > Can a rule see the where statement in a query which it has been > triggered by? or is it simply ignored?? what happens? > Looking over your question, I wanted to clarify the problem a bit, so: (cleaned up example a bit from Aasmund) -- set up

Re: [HACKERS] [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-22 Thread Stephan Szabo
On Sat, 20 Oct 2001, Joel Burton wrote: > On Sat, 20 Oct 2001, Aasmund Midttun Godal wrote: > > > Can a rule see the where statement in a query which it has been > > triggered by? or is it simply ignored?? what happens? > > > > Looking over your question, I wanted to clarify the problem a bit,

Re: [HACKERS] [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-22 Thread Stephan Szabo
> Don't think so. I think the rule doesn't make any sense. > NEW.id and OLD.id are probably dbl values, so saying OLD.id=id (where id > is raw.id since that's the update table) isn't correct. It probably > should be OLD.id=id*2 (which seems to work for me, btw) It's editing > a different row t

Re: [HACKERS] [SQL] CREATE RULE ON UPDATE/DELETE

2001-10-22 Thread Tom Lane
Joel Burton <[EMAIL PROTECTED]> writes: > CREATE VIEW dbl AS SELECT id * 2 as id, name FROM raw; > CREATE RULE dbl_update AS ON UPDATE TO dbl DO INSTEAD UPDATE raw SET > id = NEW.id, name = NEW.name WHERE OLD.id = id; Surely you'd need something like CREATE RULE dbl_update AS ON UPDATE TO dbl D