Thread: Function ROWTYPE Parameter with NEW/OLD

Function ROWTYPE Parameter with NEW/OLD

From
"Andrew Milne"
Date:
Postgres 7.2.1

I'm trying to create a function that takes a ROWTYPE parameter that I can
then call from a rule by passing NEW/OLD, but am having problems.


CREATE OR REPLACE FUNCTION "some_boolean_function" (mytablename) RETURNS
boolean AS '       DECLARE               mytable ALIAS FOR $1;       BEGIN              -- IF SOME CONDITION RETURN
TRUEELSE RETURN FALSE;       END;'       LANGUAGE 'plpgsql';
 

This works fine.

CREATE RULE some_rule AS ON UPDATE TO mytablename WHERE
(some_boolean_function(new, old)) DO INSTEAD (some other statements);

It cacks on the new and old parameters - misunderstanding on my part?
potential bug?  I have to check most of the fields in this table, so would
rather pass the whole record rather than individual fields.

Thanks,

Andrew