Обсуждение: rules on select - different output

Поиск
Список
Период
Сортировка

rules on select - different output

От
Marcin Mazurek
Дата:
Hi,

I'd like my rule to change the row which is resulting form select.
I'd like to get a row conforming to t1 from t2.
CREATE TABLE t1 (id int, f1 int, f2 int, f3 text, f4 text);
CREATE TABLE t2 (id int, p1 int, p2 text);
CREATE RULE r1 AS ON SELECT TO t2 DO INSTEAD  SELECT id, p1 AS f1, NULL::INT AS f2, p2 as f3, NULL::TEXT as f4 FROM
t2;

psql:test.sql:11: ERROR:  select rules target list must match event
relations st
ructure
test=#

Is there another way to do it?
tia
mazek