Triggers SQL Server 7 - SOCORRO
26/03/2003
0
Tenho uma trigger no SQL Server 7 que é executada no evento INSERT da tabela.
Porém esta Trigger é chamada pelo banco após eu inserir dados na tabela, e eu preciso executa-la antes de inserir estes dados, assim como no InterBase, onde existem os eventos BEFORE INSERT e AFFTER INSERT.
Existe essa possibilidade no SQL Server?
Grato
Fábio
Anonymous
Posts
26/03/2003
Aroldo Zanela
Tenho uma trigger no SQL Server 7 que é executada no evento INSERT da tabela.
Porém esta Trigger é chamada pelo banco após eu inserir dados na tabela, e eu preciso executa-la antes de inserir estes dados, assim como no InterBase, onde existem os eventos BEFORE INSERT e AFFTER INSERT.
Existe essa possibilidade no SQL Server?
Grato
Fábio[/quote:dd947b344e]
Fábio
Veja mais no books on line:
Specifying When a Trigger Fires
You can specify one of two options to control when a trigger fires:
AFTER triggers fire after the triggering action (INSERT, UPDATE, or DELETE) and after any constraints are processed. You can request AFTER triggers by specifying either the AFTER or FOR keywords. Because the FOR keyword has the same effect as AFTER, triggers with the FOR keyword are also classified as AFTER triggers.
INSTEAD OF triggers fire in place of the triggering action and before constraints are processed.
Each table or view can have one INSTEAD OF trigger for each triggering action (UPDATE, DELETE, and INSERT). A table can have several AFTER triggers for each triggering action.
Examples
A. Use the INSTEAD OF trigger to replace the standard triggering action
CREATE TRIGGER TableAInsertTrig ON TableA
INSTEAD OF INSERT
AS ...
B. Use the AFTER trigger to augment the standard triggering action
CREATE TRIGGER TableBDeleteTrig ON TableB
AFTER DELETE
AS ...
C. Use the FOR trigger to augment the standard triggering action
-- This statement uses the FOR keyword to generate an AFTER trigger.
CREATE TRIGGER TableCUpdateTrig ON TableC
FOR UPDATE
AS ...
26/03/2003
Anonymous
Fábio
26/03/2003
Aroldo Zanela
Fábio[/quote:c1ce1c0ecb]
Sorry, 2000.
Clique aqui para fazer login e interagir na Comunidade :)