Triggers SQL Server 7 - SOCORRO
Olá pessoal,
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
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
Curtidas 0
Respostas
Aroldo Zanela
26/03/2003
[quote:dd947b344e=´Fábio Alves´]Olá pessoal,
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 ...
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 ...
GOSTEI 0
Anonymous
26/03/2003
Aroldo esta dica que vc me passou foi retirada do SQL 2000 ou do SQL 7, pois no SQL 7, não estou conseguindo encontr-la?
Fábio
Fábio
GOSTEI 0
Aroldo Zanela
26/03/2003
[quote:c1ce1c0ecb=´Fábio Alves´]Aroldo esta dica que vc me passou foi retirada do SQL 2000 ou do SQL 7, pois no SQL 7, não estou conseguindo encontr-la?
Fábio[/quote:c1ce1c0ecb]
Sorry, 2000.
Fábio[/quote:c1ce1c0ecb]
Sorry, 2000.
GOSTEI 0