• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 150
  • Last Modified:

SQL Procedure Question

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
baddogi
Asked:
baddogi
  • 3
  • 2
1 Solution
 
jdc0724Commented:
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
 
baddogiAuthor Commented:
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
 
baddogiAuthor Commented:
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
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
TimCotteeHead of Software ServicesCommented:
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
 
baddogiAuthor Commented:
Thanks -  I should have thought of that :(

This should take care of it....
0
 
jdc0724Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now