Musings on Triggers

Поиск
Список
Период
Сортировка
Искать

Musings on Triggers

От:
Joshua Kramer <josh@bitbuckets.com>
Дата:

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

Re: Musings on Triggers

От:
"A. Kretschmer" <andreas.kretschmer@schollglas.com>
Дата:
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    === 

Re: Musings on Triggers

От:
Michael Fuhr <mike@fuhr.org>
Дата:
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
FAQ