If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Trigger activates with change in date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-28-03, 16:53
burningmoney burningmoney is offline
Registered User
 
Join Date: Sep 2003
Posts: 12
Trigger activates with change in date

I want to know if it is possible to activate a trigger based on a change in the system date.
The event is the change of date, rather than an update of a variable in a table.


So basically I want to achieve something like

Create or replace trigger after update OF sysdate

Or something along those lines.

Is there anyway possible????

Thanks for any help
Reply With Quote
  #2 (permalink)  
Old 12-30-03, 08:50
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
but is the date not consistently changing away?

are you referring to changing the date for a session

or

changing the date for an entiry database?


regards

edwin
Reply With Quote
  #3 (permalink)  
Old 12-30-03, 09:57
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
The Oracle DBMS_JOB package provides scheduling capabilities.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456; 12-30-03 at 10:04.
Reply With Quote
  #4 (permalink)  
Old 12-30-03, 10:11
edwinjames edwinjames is offline
Registered User
 
Join Date: Dec 2003
Posts: 74
yes but if you schedule a job to see if the date has changed with trigger everytime as the date / time is always changing.

- You should put system date into a table column each evening.

- When you run the job next day check the sysdate against the fixed stored date and this will allow you to trigger your procedure.

e.g. trunc(sysdate) != trunc(p_stored_date)

-At the end of that day then put system date into a table column again


Catch my drift?

Last edited by edwinjames; 12-31-03 at 06:29.
Reply With Quote
  #5 (permalink)  
Old 12-30-03, 10:27
r123456 r123456 is offline
Registered User
 
Join Date: Sep 2003
Location: The extremely Royal borough of Kensington, London
Posts: 778
If the DBMS was not shut down the night before, there would be no method to determine the next execution time of the procedure. Of course the user can run a procedure manually that checks the current SYSDATE agains't the stored date, however the problem is still how the SYSDATE is inserted into the table.

By implementing the DBMS_JOB package, each day at midnight the PL/SQL procedure can be executed to determine if a new month has commenced. If so then execute the relevant code. The interval between each execution of the procedure can be set to 24hrs.
__________________
Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.

Last edited by r123456; 12-30-03 at 10:39.
Reply With Quote
  #6 (permalink)  
Old 12-31-03, 04:37
burningmoney burningmoney is offline
Registered User
 
Join Date: Sep 2003
Posts: 12
Thanks everyone for the idea, the DBMS_JOB package notion does work but the assignment forbids using that functionality.

Thanks 'edwinjames' I got your drift, and have implemented it successfully.

Again thanks to everyone
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On