?
Solved

SQL Procedure Question

Posted on 2002-07-08
6
Medium Priority
?
145 Views
Last Modified: 2010-05-02
I have a tracking tool that keeps track of hours worked and hours taken beginning January 1 - December 31.  I have several stored procedures running everyday to add time to the SQL DB for the person's record based on the hire date.

The problem is when they take time and the balance returns to 0.

My question is:  How do I prevent my automatic SP's from giving the employee a new set of balances when they reach 0 during the year.
0
Comment
Question by:baddogi
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:jdc0724
ID: 7137724
A little more info specifically detailing the problem would be helpful.  You say "The problem is when they take time and the balance returns to 0".  I am assuming this could happen if say your hire date was today, you work eight hours today, and then take 8 hours off tomorrrow, leaving your balance with 0???"

What new set of balances are the Stored Procedures giving you when they reach 0??  

Cheers,
JDC0724
0
 

Author Comment

by:baddogi
ID: 7137747
Here is some more info:

Our company policy is to give employees personal and sick time based on their hire date.  Everyone begins with 0.

I have a stored procedure that checks if the balance is 0 and then adds the appropriate time.  Let's say on May 1, John Doe is eligable for 40 hours sick time and 16 hours personal time.  This stored procedure runs every day to check the difference between the hiredate and today's date.

The problem lies in that during the year once they deplete their balance back to 0, then the stored procedure will see that the balance is 0 and then give them another 40 hours of sick and 16 hours personal time in that same year.

I need some way to stop that stored procedure from running a second time within the year.

Any ideas?>
0
 

Author Comment

by:baddogi
ID: 7137749
Here is some more info:

Our company policy is to give employees personal and sick time based on their hire date.  Everyone begins with 0.

I have a stored procedure that checks if the balance is 0 and then adds the appropriate time.  Let's say on May 1, John Doe is eligable for 40 hours sick time and 16 hours personal time.  This stored procedure runs every day to check the difference between the hiredate and today's date.

The problem lies in that during the year once they deplete their balance back to 0, then the stored procedure will see that the balance is 0 and then give them another 40 hours of sick and 16 hours personal time in that same year.

I need some way to stop that stored procedure from running a second time within the year.

Any ideas?>
0
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.

 
LVL 43

Accepted Solution

by:
TimCottee earned 800 total points
ID: 7137781
Check the other field/table that records whether they have taken any time during the year. (You do have one of course!) If there are any entries/values there then don't add the values back in!
0
 

Author Comment

by:baddogi
ID: 7137813
Thanks -  I should have thought of that :(

This should take care of it....
0
 
LVL 1

Expert Comment

by:jdc0724
ID: 7137828
I am assuming that there is a set amount of months that an employee needs to work to be eligible for sick and personal time:

=== This stored procedure runs every day to check the difference between the hiredate and today's date.

Say after 6 months they become eligible and later that year they deplete the time back to 0.  Change your stored procedure to calculate the number of months between the hire date and todays date.  If greater than 6 months, and the employee has 0 time left, then you know that they have used everything for that year.  If less than or equal to 6 months, the stored procedure should do what it currently does.

Cheers,
JDC0724

0

Featured Post

Technology Partners: 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

840 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