Home » RDBMS Server » Server Administration » Trigger for populating created date field
Trigger for populating created date field [message #52902] Tue, 20 August 2002 00:41 Go to next message
HKS
Messages: 1
Registered: August 2002
Junior Member
Hi

As a standard, all our tables have created_date and modified_date. Is it worth having a trigger on every table to populate these fields, or should we just do it from the code?

Thanks
HKS
Re: Trigger for populating created date field [message #52905 is a reply to message #52902] Tue, 20 August 2002 05:01 Go to previous messageGo to next message
Mahesh Rajendran
Messages: 10707
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
creating too many triggers is not a recomended one.
Re: Trigger for populating created date field [message #52909 is a reply to message #52902] Tue, 20 August 2002 05:13 Go to previous messageGo to next message
Sanjay Bajracharya
Messages: 279
Registered: October 2001
Location: Florida
Senior Member
If your business logic permits, default the 'created_date' to 'sysdate' and do not populate this field, which will then take the sysdate. As for modified_date, in your code, put the sysdate when that row is actually modified.

You can avoid the triggers this way, at least in this case.

Cheers.
Re: Trigger for populating created date field [message #52917 is a reply to message #52902] Tue, 20 August 2002 12:42 Go to previous message
andrew again
Messages: 2577
Registered: March 2000
Senior Member
The only reason for avoiding triggers is that it gives you more code to manage. You can easily create a trigger for each table to maintain those fields. If you need some other business logic on one of thhose tables (for insert or update) then create a second trigger to hold that. In that way you can create the triggers automatically (create the trigger scripts using sqlplus or pl/sql). The coders shouldn't have to worry about populating those fields and making the business logic more difficult to follow. The advantage of a trigger is that it always fires (as long as it's enabled) irrespective of how the data gets into the table. You can track IP addresses, usernames etc too.
Previous Topic: Connect to other database
Next Topic: Urgent Help needed with Utl file
Goto Forum:
  


Current Time: Thu Sep 19 12:13:39 CDT 2024