X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id C6711D1B455 for ; Mon, 26 Apr 2004 12:38:21 -0300 (ADT) 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 95354-05 for ; Mon, 26 Apr 2004 12:38:18 -0300 (ADT) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by svr1.postgresql.org (Postfix) with ESMTP id 5C51FD1B436 for ; Mon, 26 Apr 2004 12:38:17 -0300 (ADT) Received: (from mail@localhost) by martin.sysdetect.com (8.11.4/8.11.3) id i3QFcGG31162 for ; Mon, 26 Apr 2004 15:38:16 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdD32409; Mon Apr 26 15:38:14 2004 Received: from sysd.com (thriller.sysdetect.com [172.16.1.33]) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id i3QFcEb24491 for ; Mon, 26 Apr 2004 11:38:14 -0400 Message-ID: <408D2CE5.1090108@sysd.com> Date: Mon, 26 Apr 2004 11:38:13 -0400 From: Rich Cullingford User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030703 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Tantalizing reference to passing data from NEW variable in a trigger function... Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/61 X-Sequence-Number: 4882 All, This question seems to have been asked a number of times on this list, recently (including by me) without being answered: how to pass the row data stored in the NEW variable from a trigger function into a sub-function. None of the obvious syntaxes work, including one by a respondent in this list that suggested assigning NEW to a record variable, and then passing *that*. After searching up and down the archives, I see the following tantalizing snippet (from 6/2003) in the context of a rule: Gunter Diehl writes: > create funtion f1(v, v) returns void as '...' > create rule vupt as on update to v do instead select f1(new, old) > While accepting this definitions, pg says it can not handle "whole-tuple > references" at runtime. FWIW, the "old" case works fine. "new" doesn't work so well because the new row hasn't been formed into a tuple at the point where the rule runs; it only exists as a list of variables. (This is a rather handwavy explanation, but I think it captures the key point.) While this could probably be fixed with some effort, I doubt it's going to happen soon. Is there any chance of doing what you want with a trigger instead of a rule? ^^^^^ If there's a page somewhere that says how to do this, I'd be extremely grateful for a pointer. The obvious maneuver of copying NEW's data field-by-field into a composite variable is rather unappetizing when the row is wide... Rich Cullingford rculling@sysd.com