Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Pre Update Triggers

Author  Topic 

mb
Starting Member

16 Posts

Posted - 2002-05-01 : 11:19:09
Is there anyway to use pre update triggers in SqlServer 7.0. Im trying to code some triggers which have no transactional control. Ie if a trigger detects an error the error is propogated to the application and the application performs the rollback. The problem is if a change is made using TSQL and an error is found the record seems to get commited anyway.

What I would really like to do is check to see whether there would be a problem before the record gets inserted/updated, if theres a problem dont insert-simple. Does anyone know a way to do this?

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-01 : 11:28:48
quote:

Is there anyway to use pre update triggers in SqlServer 7.0.



No . . . SQL 2k allows INSTEAD OF triggers, but all SQL 7 triggers fire after the dml.

quote:

What I would really like to do is check to see whether there would be a problem before the record gets inserted/updated, if theres a problem dont insert-simple. Does anyone know a way to do this?


yes . . . . post your code, someone will (probably) show how to change it.

<O>
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-05-01 : 11:30:27
If you write your code so that all inserts are done using stored procedures, then you can include the logic in the stored procedure to do the appropriate tests, and act accordingly. If you allow ad-hoc inserts, then you won't be able to do anything like this.

Can you upgrade to SQL Server 2000? It has INSTEAD OF triggers that can do exacly what you're looking for.

Go to Top of Page

mb
Starting Member

16 Posts

Posted - 2002-05-01 : 12:31:40
Unfortuantly we cant upgrade just yet or use stored procedures.
Thanks for the help anyway

Go to Top of Page
   

- Advertisement -