View Single Post

   
  #1 (permalink)  
Old 02-29-2008, 07:09 AM
Jon
 
Posts: n/a
Default prevent DELETE and/or UPDATE

Hi all!
Are there any other way than using rights or Triggers to prevent a
DELETE or an UPDATE on a specific column.

The "problem" with rights is that they dont apply to all DB-users

The "problem" with triggers is that they generate lots of extra
SQL-code

I would like a solution something like below. If there are any
primitives like this or other more neat solutions I would be glad to
know



CREATE TABLE some_table NO DELETE
/* ^^^^^^^^^*/
(
some_column SOME_TYPE NO UPDATE
/* ^^^^^^^^^*/

)


For clarity, here is a trigger that currently solves the problem

CREATE TRIGGER check_updateable_columns ON some_table
FOR UPDATE
AS
IF UPDATE(some_column)
RAISERROR(...)
GO

or

CREATE TRIGGER delete_not_allowed ON some_table
INSTEAD OF DELETE
AS
RAISERROR(...)
GO
Reply With Quote