Solved

Conditional execution in Teradata Stored Procedure based on date value

Posted on 2009-07-13
1
1,175 Views
Last Modified: 2013-11-11
I'm creating a stored procedure that checks the quality of the data loaded into our data warehouse on a daily basis.  Most of the table checks in the stored procedure run on a daily basis.  However, some of the table checks only need to run once a month as they are tables that are only loaded once a month.

I was curious if it was possible within the stored procedure to set some kind of condition that would permit that particular block of code to only execute when the date value equalled the first of the month?

Thank you!
0
Comment
Question by:SpeedsterZ28
1 Comment
 
LVL 22

Accepted Solution

by:
8080_Diver earned 500 total points
ID: 24846123
Why not check the system date's day of month to see if it is equal to a 1?
Of course, the issue would be, what if the system is down on the first through 3rd of the month?  So, what I would suggest is a "cheat" that I use for various similar tasks that I have created.  Create a simle little controlling table that has the task name, a last run date, a RunInterval, and a NextRun date or .  Then you populate that table with the appropriate information and, in you process, you check to see if today is >= NextRunDate.  If it is, then you execute that step in the process and, upon successful completion, update the Last Run Date and set the NextRunDate (of course, on a failure, you don't touch the control table row ;-).  That way, you can see the date of the last successful run and then next scheduled Run Date.  (If you want to get fancy, you can have a column for Days, one for Months, and one for Years to increment the NextRunDate. ;-)
 
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Note: You must have administrative privileges in order to create/edit Roles. Salesforce.com (http://www.salesforce.com/) (SFDC) is a cloud-based customer relationship management (CRM) system. It is a database most commonly used by sales and marke…
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 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