X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 84C8F563C1 for ; Tue, 8 Mar 2005 22:57:23 +0000 (GMT) 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 26516-04 for ; Tue, 8 Mar 2005 22:57:22 +0000 (GMT) Received: from priv-edtnes56.telusplanet.net (outbound01.telus.net [199.185.220.220]) by svr1.postgresql.org (Postfix) with ESMTP id 0716C563B8 for ; Tue, 8 Mar 2005 22:57:21 +0000 (GMT) Received: from [127.0.0.1] (really [207.194.253.61]) by priv-edtnes56.telusplanet.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050308225723.GIKV18457.priv-edtnes56.telusplanet.net@[127.0.0.1]> for ; Tue, 8 Mar 2005 15:57:23 -0700 Message-ID: <422E2DD4.1070509@telus.net> Date: Tue, 08 Mar 2005 14:57:24 -0800 From: pw User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Question about accessing current row data inside trigger Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.426 tagged_above=0 required=5 tests=DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200503/26 X-Sequence-Number: 5355 *previously posted this to pgsql-general* -Hello, - -I have a trigger function written in C. -The trigger function is called via: - -CREATE TRIGGER after_update AFTER UPDATE ON some_table - FOR EACH ROW EXECUTE PROCEDURE my_trigger_function(); - - Since the trigger is called after each row update the actual -row data -should be available in some way to the trigger. - - What functionality (SPI ?) do I use to use the column values -from the -current row in the actual trigger? - - Does SPI_cursor_fetch automatically give me the current trigger -row or -do I need to query again for the proper row? - -thanks for any insight, - -Peter I am now using : TupleTableSlot *t = (TupleTableSlot *) PG_GETARG_POINTER(0); bool isnull; char *buffer=(char *)DatumGetPointer(GetAttributeByName(t, "some_column_name", &isnull)); The pointer always comes back NULL though there is data in the column. I'm still not sure this is the correct way to access the data from the updated row. Is this the correct way to get a string back from the data in the column named 'some_column_name'? Do I have the correct TupleTableSlot pointer? Thanks for any insight, Peter