Triggers SQL Server 7 - SOCORRO

26/03/2003

0

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


Anonymous

Anonymous

Responder

Posts

26/03/2003

Aroldo Zanela

[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 ...


Responder

26/03/2003

Anonymous

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


Responder

26/03/2003

Aroldo Zanela

[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.


Responder

APRENDA A PROGRAMAR DO ZERO AO PROFISSIONAL

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar