Re: BUG #5400: Columns count mismatch in RULE with subquery

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Teodor Buchner" <t(dot)buchner(at)autoguard(dot)pl>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5400: Columns count mismatch in RULE with subquery
Date: 2010-03-31 14:35:17
Message-ID: 20806.1270046117@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

"Teodor Buchner" <t(dot)buchner(at)autoguard(dot)pl> writes:
> CREATE OR REPLACE RULE move_iteration_1 AS ON INSERT TO a.iteration DO ALSO

> INSERT INTO b.iteration(id,date_period_begin)
> SELECT (NEW.id,NEW.date_period_begin) FROM a.iteration;

Your use of parentheses in the SELECT targetlist is incorrect (and would
be with or without the RULE context). What this is trying to do is
insert a single composite column into the target table. You want

INSERT INTO b.iteration(id,date_period_begin)
SELECT NEW.id,NEW.date_period_begin FROM a.iteration;

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andy Balholm 2010-03-31 17:52:54 Re: dividing money by money
Previous Message Kevin Grittner 2010-03-31 14:07:49 Re: dividing money by money