Received: from mail01.phoenixdsl.com (mail.phoenixdsl.com [216.178.151.24]) by mail.postgresql.org (8.11.1/8.11.1) with SMTP id f15FSsx17520 for ; Mon, 5 Feb 2001 10:28:54 -0500 (EST) (envelope-from mdavis@sevainc.com) Received: (qmail 6056 invoked by uid 89); 5 Feb 2001 15:28:50 -0000 Received: from unknown (HELO SALLY) (64.32.157.45) by 0 with SMTP; 5 Feb 2001 15:28:50 -0000 Received: by localhost with Microsoft MAPI; Mon, 5 Feb 2001 08:28:48 -0700 Message-ID: <01C08F4D.A9B6D800.mdavis@sevainc.com> From: Michael Davis Reply-To: "mdavis@sevainc.com" To: "'Joe Conway'" , "pgsql-sql@postgresql.org" Subject: RE: C function for use from PLpgSQL trigger Date: Mon, 5 Feb 2001 08:28:43 -0700 Organization: Seva Inc. X-Mailer: Microsoft Internet E-mail/MAPI - 8.0.0.4211 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Archive-Number: 200102/45 X-Sequence-Number: 1215 You could send the column name directly into your c function. For example: c_function_name(NEW.col1, NEW.col2, NEW.col3). Otherwise I am not sure how to send NEW into a C function. You could try declaring NEW in your C function as a tuple. -----Original Message----- From: Joe Conway [SMTP:jconway2@home.com] Sent: Sunday, February 04, 2001 1:04 AM To: pgsql-sql@postgresql.org Subject: Fw: C function for use from PLpgSQL trigger Hello all, I posted this (see below) Friday to the interfaces list with no response. Does anyone know if what I'm trying to do is possible, or should I just write the entire thing in a C function trigger? The latter would be unfortunate because I think it would be nice to be able to extend PLpgSQL using C functions like this. Anyway, any help or advice will be much appreciated! Thanks, Joe > Hi, > > I'm trying to create a C function that I can call from within a PLpgSQL > trigger function which will return a list of all the values in the NEW > record formatted suitably for an insert statement. I can't come up with a > way to do this directly from within PLpgSQL (i.e. iterate through an > arbitrary number of NEW.attribute). > > Can anyone tell me how I can either pass the NEW record to the C function > (this produces an error message 'NEW used in a non-rule query') or gain > access to the trigger tuple from within my C function? It seems that > although PLpgSQL is called as a trigger, the C function is called as a > regular function (makes sense) and thus has no access to the trigger tuple > (my problem). > > Any help or guidance is greatly appreciated! > > Thanks, > > Joe Conway >