niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » PostgreSQL
Question about accessing current row data inside trigger
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
Author Message
peter Willis
*nix forums beginner


Joined: 08 Mar 2005
Posts: 3

PostPosted: Tue Mar 08, 2005 6:37 pm    Post subject: Question about accessing current row data inside trigger Reply with quote

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?

thanks for any insight,

Peter



---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Back to top
Michael Fuhr
*nix forums Guru


Joined: 02 Mar 2005
Posts: 674

PostPosted: Mon Mar 14, 2005 4:47 am    Post subject: Re: Question about accessing current row data inside trigger Reply with quote

On Tue, Mar 08, 2005 at 11:37:14AM -0800, peter Willis wrote:

Quote:
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?

See "Writing Trigger Functions in C" and "C-Language Functions" in
the documentation. Here are links to documentation for the latest
version of PostgreSQL:

http://www.postgresql.org/docs/8.0/interactive/trigger-interface.html
http://www.postgresql.org/docs/8.0/interactive/xfunc-c.html

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Back to top
Tom Lane
*nix forums Guru


Joined: 24 Mar 2005
Posts: 2070

PostPosted: Mon Mar 14, 2005 5:35 am    Post subject: Re: Question about accessing current row data inside trigger Reply with quote

peter Willis <peterw@borstad.com> writes:
Quote:
I have a trigger function written in C.
...
Since the trigger is called after each row update the actual row data
should be available in some way to the trigger.

Sure: tg_trigtuple or tg_newtuple depending on which state you want.
See
http://www.postgresql.org/docs/8.0/static/trigger-interface.html

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
Back to top
peter Willis
*nix forums beginner


Joined: 08 Mar 2005
Posts: 3

PostPosted: Mon Mar 14, 2005 2:56 pm    Post subject: Re: Question about accessing current row data inside trigger Reply with quote

Hello,

I resolved this issue already.
The trigger now works fine.
I was looking at the wrong structure.

Thanks,

Peter


Michael Fuhr wrote:

Quote:
On Tue, Mar 08, 2005 at 11:37:14AM -0800, peter Willis wrote:



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?



See "Writing Trigger Functions in C" and "C-Language Functions" in
the documentation. Here are links to documentation for the latest
version of PostgreSQL:

http://www.postgresql.org/docs/8.0/interactive/trigger-interface.html
http://www.postgresql.org/docs/8.0/interactive/xfunc-c.html






---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
Back to top
peter Willis
*nix forums beginner


Joined: 08 Mar 2005
Posts: 3

PostPosted: Mon Mar 14, 2005 2:59 pm    Post subject: Re: Question about accessing current row data inside trigger Reply with quote

Hello,

This issue is resolved.
I was using the wrong struct.

Peter


Tom Lane wrote:

Quote:
peter Willis <peterw@borstad.com> writes:


I have a trigger function written in C.
...
Since the trigger is called after each row update the actual row data
should be available in some way to the trigger.



Sure: tg_trigtuple or tg_newtuple depending on which state you want.
See
http://www.postgresql.org/docs/8.0/static/trigger-interface.html

regards, tom lane







---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [5 Posts] View previous topic :: View next topic
The time now is Fri Jan 09, 2009 6:15 am | All times are GMT
navigation Forum index » Databases » PostgreSQL
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Newbie question: How to forward a domain to a mailbox? leei Postfix 0 Fri Aug 24, 2007 4:55 pm
No new posts configuration question for httpd Karl Wang Apache 1 Fri Jul 21, 2006 2:10 pm
No new posts nim problem/question Ron AIX 0 Fri Jul 21, 2006 1:57 pm
No new posts Problem while accessing 64 bit Server thru 32 bit client Ganesh Server 0 Fri Jul 21, 2006 1:40 pm
No new posts What is current status of frameworks? Which to choose? Marek Zawadzki PHP 1 Fri Jul 21, 2006 1:05 pm

Mobile Phone | Credit Card Advice | Bankruptcy | Mobile Phone | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2607s ][ Queries: 16 (0.1768s) ][ GZIP on - Debug on ]