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)
 Conditional Update

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---DateEntered
1------100---10/06/2005
2------110---11/01/2005

The 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.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2005-11-07 : 12:56:03
I still don't get it...could read the hint link in my sig, and give us some more details?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

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...
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -