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.
| Author |
Topic |
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2005-11-07 : 12:42:57
|
| I need to implement a business rule that will restrict the update to a field based on the elapse of time bewteen a date field value and the time of the update. For instance,RowID--Qty---DateEntered1------100---10/06/20052------110---11/01/2005The Qty is only updatable if the update is done within 30 days from the DateEntered date. In another words, above row 1 is not updatable, but row 2 is updatable. The presentation layers are in mixed environments, so it calls for the implementation on the SQL server.What is the right way to have this done? A before update trigger, a some sort of check constraint?The updates are not always coming from a store procedure, and performance is not too big a concern.Thanks! |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2005-11-07 : 12:48:02
|
quote: What is the right way to have this done?
quote: The updates are not always coming from a store procedure, and performance is not too big a concern.
Well, THERE'S your problem. You should not be allowing direct updates to production tables. This logic properly belongs in the stored procedure, not a trigger. You are going to have a hard time implementing datetime logic in a trigger, since GETDATE() is non-deterministic and is not allowed in triggers. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2005-11-07 : 13:28:08
|
Hey Brett. Maybe you could save some typing by putting a note in your signature directing people to read your signature. Just a thought... |
 |
|
|
Hommer
Aged Yak Warrior
808 Posts |
Posted - 2005-11-07 : 13:46:46
|
| Brett, I have corrected several typos. I think my post is straight forward, and BLINED MAN sees my dilemma clearly. However, I have no control over who should and how should they access the production data. |
 |
|
|
|
|
|
|
|