X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 2052BD1B584 for ; Mon, 17 Nov 2003 18:08:42 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 18435-04 for ; Mon, 17 Nov 2003 14:08:11 -0400 (AST) Received: from enforcer.solutionip.com (enforcerxii.solutionip.com [216.83.4.32]) by svr1.postgresql.org (Postfix) with ESMTP id 4DB64D1BB46 for ; Mon, 17 Nov 2003 14:08:09 -0400 (AST) Received: from [172.28.16.141] (helo=milne) by enforcer.solutionip.com with smtp (Exim 3.34 #1) id 1ALnn0-0008Dt-00 for pgsql-sql@postgresql.org; Mon, 17 Nov 2003 14:07:54 -0400 From: "Andrew Milne" To: Subject: Function ROWTYPE Parameter with NEW/OLD Date: Mon, 17 Nov 2003 14:08:40 -0400 Message-ID: <001501c3ad35$d46708a0$8d101cac@solutionip.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=3.8 tagged_above=0.0 required=5.0 tests=FORGED_MUA_OIMO, UPPERCASE_25_50 X-Spam-Level: *** X-Archive-Number: 200311/219 X-Sequence-Number: 16034 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 TRUE ELSE 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