>> But I don't understand why the nextval('sessions_id_seq') is evaluated
>> multiple times? Even when I do
>
> RULE expand like macros, so every expression passed in is simply copied
> to each place, leading to multiple evaluations.
>
> If you've played with the C preprocessor: that has the same basic
> problem.
>
> It's rather unexpected for novices, which is why triggers are usually
> recommended.
I wouldn't call myself a novice, but yes - this surprised me a little.
Now it seems so natural ... I think there should be a clear explanation
/ example in the docs about this - I've read the documentation on RULE
sytem several times and as far as I remember.
Anyway thanks to those helped me to solve this problem, now it works as
expected.
Tomas