Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Conditional execution in Teradata Stored Procedure based on date value

Posted on 2009-07-13
1
Medium Priority
?
1,194 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

718 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