Solved

Oracle Time Stamp

Posted on 1998-05-10
4
1,402 Views
Last Modified: 2008-02-01
Is there a way we can put a column in 'history' table that would keep the time, at which transaction x was commited?
0
Comment
Question by:kgkhan
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
xiaodong earned 100 total points
Comment Utility
Absolutely.
Add a colume with data type of Date.
Whenever you insert/update a record, insert/update the column with the value of sysdate.
0
 
LVL 2

Expert Comment

by:manand062397
Comment Utility
As Xiaodong said add new field for date field and do the followings

1. Use Trigger to update new field automatically on insert/update of record.

2. If you do not update records in history table then user default sysdate to update date and time of insertion.  

If you do not update history records then I recommend second method because there is no coding.
0
 
LVL 4

Expert Comment

by:sganta
Comment Utility
You follow the following steps

1. To include column in the history table using the following syntax
    SQL >     ALTER TABLE history ADD (record_date DATE);
2. Now write a DATA BASE TRIGGER for history which will take care to insert or update
   the  RECORD_DATE by using the following SYNTAX

   CREATE TRIGGER history_trigger
   BEFORE INSERT OR UPDATE ON history FOR EACH ROW
   BEGIN
       :NEW.record_date := SYSDATE;
   END;
3. Execute the above trigger which will fire whenever you insert or update the record
   and change the  update the committed time accordingly.

Since the question is locked, I could'nt able to answer you.

This is tested and it works fine
I hope this is acceptable to you - sganta


0
 
LVL 4

Expert Comment

by:sganta
Comment Utility
Hello !

I have posted my answer as a comment. Since the Question is locked, I could'nt able
to put in to answer column.

If you are interested in xiaodong's answer please accept this. Otherwise
reject this. If you are not interested in my answer (comment). Send a comment
so that another expert can give better solution. You've taken so much time.
What happened ?
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Oracle SQL Select Statement 19 58
oracle query 15 62
Need help with Oracle syntax 4 39
sql query 9 16
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now