Re: BUG #5400: Columns count mismatch in RULE with subquery - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #5400: Columns count mismatch in RULE with subquery
Date
Msg-id 20806.1270046117@sss.pgh.pa.us
Whole thread Raw
In response to BUG #5400: Columns count mismatch in RULE with subquery  ("Teodor Buchner" <t.buchner@autoguard.pl>)
List pgsql-bugs
"Teodor Buchner" <t.buchner@autoguard.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

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: dividing money by money
Next
From: Andy Balholm
Date:
Subject: Re: dividing money by money