LastModifiedDate
-
Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??
Keep DotNetting!! GeekFromIndia
-
Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??
Keep DotNetting!! GeekFromIndia
-
we are not using separate procs but every procs that updates any table...it updates this column also...
Keep DotNetting!! GeekFromIndia
-
we are not using separate procs but every procs that updates any table...it updates this column also...
Keep DotNetting!! GeekFromIndia
So is every update and insert done via stored procedure and the developers are writing the procedures? If that is true I would still go to triggers. In this way the database takes care of critical information (I understood that the date must be modified every time) and the developers don't have to remember to add this column to every DML operation. Also DML executed directly against the table is setting the date correctly if triggers are used. Just wondering how you use the LastModifiedDate. If it simply shows the date when the record is last modified, it's ok. However if you use it for optimistic locking, the resolution isn't adequate. Mika
-
So is every update and insert done via stored procedure and the developers are writing the procedures? If that is true I would still go to triggers. In this way the database takes care of critical information (I understood that the date must be modified every time) and the developers don't have to remember to add this column to every DML operation. Also DML executed directly against the table is setting the date correctly if triggers are used. Just wondering how you use the LastModifiedDate. If it simply shows the date when the record is last modified, it's ok. However if you use it for optimistic locking, the resolution isn't adequate. Mika
Thanks Mika, We are using it to update date for any change in the table...i guess i will be using triggers only.. thanks again for help
Keep DotNetting!! GeekFromIndia
-
Thanks Mika, We are using it to update date for any change in the table...i guess i will be using triggers only.. thanks again for help
Keep DotNetting!! GeekFromIndia
-
Hi guys, We have a column "LastModifiedDate" columns in almost all our tables. We are currently using procedures to update lastupdateddate column. but every now and then developers forget to add this to their query. Is their a way to make this automatic...should we use triggers for this??... But again I m not sure if we should add triggers to all tables... what's the best practice for this? Any suggestions??
Keep DotNetting!! GeekFromIndia
Hi, i don´t know if i can help you there but use sql getdatetime() function to get date automatically. You will get time when the procedure is triggered, don´t even need to ask nothing to the user. I had a application on which i manage the login/logout process automatically, the user doesn´t even know that it exists algorithm: create table log_table(id int,user varchar(50),login smalldatetime, logout smalldatetime) --in login procedure insert into log_table(235,john,getdatetime(), null) --in logout procedure insert into log_table(235,john,null,getdatetime()) Good Luck :-D
-
Hi, i don´t know if i can help you there but use sql getdatetime() function to get date automatically. You will get time when the procedure is triggered, don´t even need to ask nothing to the user. I had a application on which i manage the login/logout process automatically, the user doesn´t even know that it exists algorithm: create table log_table(id int,user varchar(50),login smalldatetime, logout smalldatetime) --in login procedure insert into log_table(235,john,getdatetime(), null) --in logout procedure insert into log_table(235,john,null,getdatetime()) Good Luck :-D
yeah...thats the way we are doing right now... but if your table is accessible at many places/procs in application it can be difficult to manage or make sure that every developer is adding this attribute. if anyone missed it..our business logic will fail...so i feel its better to add a trigger once and forget about it.. but i was wondering if there are any disadvantages of using triggers???
Keep DotNetting!! GeekFromIndia