Unix Technical Forum

Musings on Triggers

This is a discussion on Musings on Triggers within the pgsql Novice forums, part of the PostgreSQL category; --> Greetings all, Can anyone recommend a tutorial on writing triggers, aside from what's in the documentation? Can a trigger ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 09:21 PM
Joshua Kramer
 
Posts: n/a
Default Musings on Triggers


Greetings all,

Can anyone recommend a tutorial on writing triggers, aside from what's in
the documentation?

Can a trigger in a table in Database_A alter/insert data in a table in
Database_B?

Can I write a trigger such that, it runs on every insert into Table_A, and
inserts a subset of fields of this insert into Table_B, but if this is not
successful, then the insert on Table_A also fails?

Thanks
-Josh


---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 09:21 PM
A. Kretschmer
 
Posts: n/a
Default Re: Musings on Triggers

am 06.12.2005, um 10:49:31 -0500 mailte Joshua Kramer folgendes:
>
> Greetings all,
>
> Can anyone recommend a tutorial on writing triggers, aside from what's in
> the documentation?
>
> Can a trigger in a table in Database_A alter/insert data in a table in
> Database_B?


No, you can't. (except with dblink)


>
> Can I write a trigger such that, it runs on every insert into Table_A, and
> inserts a subset of fields of this insert into Table_B, but if this is not
> successful, then the insert on Table_A also fails?


Yes.


HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 09:21 PM
Michael Fuhr
 
Posts: n/a
Default Re: Musings on Triggers

On Tue, Dec 06, 2005 at 05:36:45PM +0100, A. Kretschmer wrote:
> am 06.12.2005, um 10:49:31 -0500 mailte Joshua Kramer folgendes:
> > Can a trigger in a table in Database_A alter/insert data in a table in
> > Database_B?

>
> No, you can't. (except with dblink)


Or with procedural languages like PL/Perl that allow you to do just
about anything you want (connect to another database, send email,
etc.). However, a drawback is that you don't get transactional
semantics: if you roll back the transaction there's no way to undo
the trigger's actions.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:52 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com