Solved

Conditional execution in Teradata Stored Procedure based on date value

Posted on 2009-07-13
1
1,156 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Note: You must have administrative privileges in order to configure lead or case queues. Salesforce.com (http://www.Salesforce.com) is a cloud-based customer relationship management (CRM) system. It is widely used around the world by sales and ma…
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

744 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

16 Experts available now in Live!

Get 1:1 Help Now