> create rule surveys_ins as on insert to surveys
> do instead
> insert into survey_data (survey_date, name)
> select new.survey_date, new.name where not exists
> (select * from survey_data d where d.survey_date = new.survey_date
> and d.name = new.name);
>
Since this is a rewrite rule, the whole statement gets rewritten, thus
leading to different results, when one statement inserts many rows (insert
into ... select)
or one statement only inserts one row (insert ...).
The "problem" is visibility of data. The rows that have already been
inserted by this
same statement (insert ...select) are not visible to the restricting select.
Andreas