X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 826DF5E46EE for ; Wed, 25 Aug 2004 11:21:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88372-03 for ; Wed, 25 Aug 2004 14:21:57 +0000 (GMT) Received: from smtp.net4b.pt (out.net4b.pt [195.245.176.1]) by svr1.postgresql.org (Postfix) with ESMTP id C94815E46C3 for ; Wed, 25 Aug 2004 11:21:51 -0300 (ADT) Received: (qmail 6147 invoked from network); 25 Aug 2004 15:22:48 +0100 Received: from smtp.oninetspeed.pt (HELO filo.at.isp) ([195.245.128.200]) (envelope-sender ) by smtp.net4b.pt (qmail-ldap-1.03) with SMTP for ; 25 Aug 2004 15:22:48 +0100 Received: from [213.58.190.132] ([213.58.190.132]) by filo.at.isp with Microsoft SMTPSVC(5.0.2195.6713); Wed, 25 Aug 2004 15:21:03 +0100 Message-ID: <412CA074.2000606@netcabo.pt> Date: Wed, 25 Aug 2004 15:21:40 +0100 From: "Pedro B." User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: PQexec and SPI_exec Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 Aug 2004 14:21:06.0336 (UTC) FILETIME=[C261FA00:01C48AAE] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/262 X-Sequence-Number: 18759 Hello everyone. I'm experiencing some doubts regarding a procedure i have (.c compiled as .so) running as an 'after insert for each row' trigger. This trigger is supposed to do a simple query, something like SELECT * FROM table order by id where processed=0 limit 1 It's not the perfect way to get the vars of the insert itself, but the result is a set of 45 columns, and the operations of the trigger are somehow complex, so .c is really a necessity on this one, and as long as this select actually returns the proper values, i can deal with it later. But my problem is not one of a structure nature: my problem is the fact that using SPI_exec, and the SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, columnX), and DatumGetInt32(DirectFunctionCall1(int4in, CStringGetDatum(SPI_getvalue(SPI_tuptable->vals[0], SPI_tuptable->tupdesc, columnX)))), etc, it all works fine. the SPI-running-from-the-triggered-.so can detect the correct values - from the insert that triggered it. I would prefer to use the more friendly PQexec and the simpler PQgetvalue(res,0,X), but this last approach does not return the values of the insert that triggered it. It returns the values from the "the last insert before this one". What is the proper way to make this method work? I'm sorry if this might be a basic question, but i have tried so many things, that i'm probably too puzzled right now to make any sense. Any help is deeply appreciated. Thanks, \\Pedro