vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi everybody! I need create trigger in firebird and mssql. The trigger must do this: If someone try to delete record in table "mast_trans" and if column "ID" is equal 145 delete cannot be executed otherwise perform delete. How can I do this? My books dont have any examples for this Thanks for help, greetings, gregory. |
| |||
| On Tue, 06 Apr 2004 11:46:23 +0200, rozrabiak wrote: >Hi everybody! >I need create trigger in firebird and mssql. >The trigger must do this: > >If someone try to delete record in table "mast_trans" and if column "ID" >is equal 145 delete cannot be executed otherwise perform delete. > >How can I do this? My books dont have any examples for this > >Thanks for help, greetings, gregory. Don't know about firebird. In SQL Server: CREATE TRIGGER MyTrigger ON mast_trans AFTER DELETE AS IF EXISTS (SELECT * FROM deleted WHERE ID = 145) BEGIN RAISERROR ('Row 145 can't be deleted - transaction aborted.', 16, 1) ROLLBACK TRANSACTION END Best, Hugo -- (Remove _NO_ and _SPAM_ to get my e-mail address) |
| ||||
| rozrabiak <brak@maila.pl> wrote in message news:<c4tua9$g8p$1@news.onet.pl>... > Hi everybody! > I need create trigger in firebird and mssql. > The trigger must do this: > > If someone try to delete record in table "mast_trans" and if column "ID" > is equal 145 delete cannot be executed otherwise perform delete. > > How can I do this? My books dont have any examples for this > > Thanks for help, greetings, gregory. Here is one possible way, for MSSQL: create trigger dbo.TestTrig on dbo.mast_trans instead of delete as begin if @@rowcount = 0 return else delete from dbo.mast_trans where PrimaryKey in (select PrimaryKey from deleted where id <> 145) end Simon |