Skip site navigation (1) Skip section navigation (2)

Question about accessing current row data inside trigger

From: pw <p(dot)willis(at)telus(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Question about accessing current row data inside trigger
Date: 2005-03-08 22:57:24
Message-ID: 422E2DD4.1070509@telus.net (view raw or flat)
Thread:
Lists: pgsql-interfaces
*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


Responses

pgsql-interfaces by date

Next:From: Jim ButtafuocoDate: 2005-03-08 23:27:06
Subject: Re: Question about accessing current row data inside trigger
Previous:From: Bruce MomjianDate: 2005-03-07 21:21:49
Subject: Re: [INTERFACES] bcc32.mak for libpq broken? (distro 8.0.0)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group