Monday, March 26, 2012

making record read-only

Hi,

i want to make a certain records read-only using stored procedure. something like:

Update dbo.Articles
SET record = "read-only"
WHERE
ArticleID = @.ArticleID

(you know what i mean)

the reason i want to do that is that im publishing articles and i want to lock the articles once they're published so no body can change them unless they're unpublished.

of course i aslo want to know how to make a record read-write again.

ThanxAnswer: you can not. Row level security is not part of SQL.

What yo ucould do is a Trigger that blos and rolld back the transaction when a row has a specific value (read only flag).

But then - why the heck dont you handle this in the frontend application? Just dont let the user delete.|||well i wanted i did that in the front end.. just wanted to do it at the backend to ensure data integrity.

Thank you|||::just wanted to do it at the backend to ensure data integrity.

Sadly, this is nonsense, as this does not touch the issue of data integrity. Relational integrity has nothing to do with being able to delete something or not.

Now, in the rare case this needs to be blocked, a trigger that blows the transaction is about the only way to go :-)sql

No comments:

Post a Comment