Christian,
> I need to hold an integer value and use it in some queries in a rule I
> have. I tried to use a temporary table, but without luck (got an error
> like Relation "tmpfoo" does not exist ).
>
> My question is: How can I hold this value thoughout the rule? Can I use
> variables of some sort?
Have the rule execute a PL/pgSQL function. PL/pgSQL has full variable
support; see the documentation under "procedural functions".