Solved

Conditional execution in Teradata Stored Procedure based on date value

Posted on 2009-07-13
1
1,181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 Sharing Rules. 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 an…
Get to know the ins and outs of building a web-based ERP system for your enterprise. Development timeline, technology, and costs outlined.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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