Possible Duplicate:
Trigger based on sysdate
1.I have a table on which i have to perform update operations everyday at 12:00(24 Hr. Format).
How should I accomplish this?
Table Schema:
CREATE TABLE CHARGES
(
total NUMBER(30),
admitdate TIMESTAMP(6),
dischargedate TIMESTAMP(30)
)
Update Algorithm:
if
{
dischargedate="null"
then total=admitdate-sysdate=difference in days * Total
Do this every day at 12:00(24 Hr. Format)
}
else
{
do nothing.
}
The standard to run a job every 24 hours would be to run a job at this interval using the system package
DBMS_SCHEDULER.For instance:
You then create a procedure to run:
This would update the column total to be the number of days between the
admitdateand SYSDATE.However, I question the need to do this at all. It sounds very much like the age-old “Should I store Age” question. I believe the answer is no. You are absolutely bound to be wrong at some point and there are a number of possibilities that might cause the job to be manually run incorrectly. I would calculate this column on the fly as you extract data from the database.