X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 90D40CCC92 for ; Fri, 18 Jul 2003 09:18:57 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 68747-02 for ; Fri, 18 Jul 2003 09:19:15 +0000 (GMT) Received: from isd.canberra.edu.au (isd.canberra.edu.au [137.92.10.5]) by svr1.postgresql.org (Postfix) with ESMTP id 00CBFCCC8C for ; Fri, 18 Jul 2003 06:18:45 -0300 (ADT) Received: from cts.canberra.edu.au (fooey.canberra.edu.au [137.92.10.57]) by isd.canberra.edu.au (8.12.9/8.12.6) with ESMTP id h6I9IuCF009226; Fri, 18 Jul 2003 19:18:56 +1000 (EST) Message-ID: <3F17BB5C.4020803@cts.canberra.edu.au> Date: Fri, 18 Jul 2003 19:18:20 +1000 From: Terence Kearns User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.3.1) Gecko/20030425 X-Accept-Language: en-au, en-gb, en, en-us MIME-Version: 1.0 To: Richard Huxton Cc: Terence Kearns , pgsql-sql@postgresql.org Subject: Re: (trigger function) -> ERROR: NEW used in non-rule query References: <3F17AE38.5020302@cts.canberra.edu.au> <200307181003.42279.dev@archonet.com> In-Reply-To: <200307181003.42279.dev@archonet.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/251 X-Sequence-Number: 14365 Richard Huxton wrote: > On Friday 18 Jul 2003 9:22 am, Terence Kearns wrote: > >>I'm writing a trigger which wants to reference the pre-defined NEW record. >> >>I can do this >>idval := NEW.blah; >> >>This works fine!!! >> >>What I really need to do is >>idval := NEW.(quote_ident(TG_ARGV[3])); >>or this >>idval := NEW.(TG_ARGV[3]); > > > I'll give you the short answer - no you can't do this (in plpgsql). Which > isn't to say it'll never be possible, but not at the moment. > > Can you afford to look at an alternative language? I'd suggest looking at TCL, > although I must admit I've never used it myself. > > damn. There's realy no other way for me to access the value since the trigger function will be called from different relations. I tried idval := (''NEW.'' || TG_ARGV[3]); but recieved ERROR: pf_atoi: error in "NEW.blah": can't parse "NEW.blah" Oh well, can't win them all :/ Well I suppose I could try TCL. The problem is that there is little to no documentation on postgres stored procedures in TCL and I've never even seen the language before. None the less, I'll look into it. It's almost worth it. If that fails, I may even try perl . if that files, I will try to get --with-python to configure (which it's refusing to do at the moment even though I have a working installation). -- Terence Kearns ~ ph: +61 2 6201 5516 IT Database/Applications Developer Enterprise Information Systems Client Services Division University of Canberra www.canberra.edu.au