Solved

Conditional execution in Teradata Stored Procedure based on date value

Posted on 2009-07-13
1
1,187 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Salesforce.com is a cloud-based customer relationship management (CRM) system. In this article, you will learn how to add and map custom lead and contact fields to your Salesforce instance.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

630 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