pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedQuestion about accessing current row data inside trigger
2+ messages / 2 participants
[nested] [flat]
* Question about accessing current row data inside trigger
@ 2005-03-08 22:57 pw <p.willis@telus.net>
0 siblings, 1 reply; 2+ messages in thread
From: pw @ 2005-03-08 22:57 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Question about accessing current row data inside trigger
@ 2005-03-08 23:27 Jim Buttafuoco <jim@contactbda.com>
parent: pw <p.willis@telus.net>
0 siblings, 0 replies; 2+ messages in thread
From: Jim Buttafuoco @ 2005-03-08 23:27 UTC (permalink / raw)
To: pw <p.willis@telus.net>; pgsql-interfaces
have you looked in the contrib directory (Postgresql 7.4.6). I just checked and the dbmirror/pending.c looks like
some good code to follow.
Jim
---------- Original Message -----------
From: pw <p.willis@telus.net>
To: pgsql-interfaces@postgresql.org
Sent: Tue, 08 Mar 2005 14:57:24 -0800
Subject: [INTERFACES] Question about accessing current row data inside trigger
> *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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
------- End of Original Message -------
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2005-03-08 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-08 22:57 Question about accessing current row data inside trigger pw <p.willis@telus.net>
2005-03-08 23:27 ` Jim Buttafuoco <jim@contactbda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox