Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reuse key value of deleted index key on un-packed table

Status
Not open for further replies.

spuppett

Programmer
Jan 25, 2003
48
US
I'm maintaining an old VFP 6.0 company phonebook program. One of the IT guys was wondering if it was possible to re-use an employee id (not really an employee id, but for the sake of the program, thats what it is) after an employee 'leaves'. What has to happen now, is the IT guy has to wait until after hours and nobody is in the program, then open the table and pack the table. I tried SET DELETED ON, but that didn't work.

Does anyone have a suggestion on how to acheive this?
 
If you can find the un-used Employee ID's then you have a variety of options.

1. As you have already suggested, DELETE it and then eventually PACK it out of the table -- but it requires EXCLUSIVE use of the table.

2. Go to the un-used Employee ID and change all of the record values (perhaps insert new employee values or blank them???). Then use the record again any way you wish.

Good Luck,
JRB-Bldr
 

Personally, I wouldn't bother. Unless you have a very limited range of ID values to choose from, just keep assigning new IDs for each new employee.

Depending on how volatile your staff are (hmm, that doesn't sound right ... I should have said: depending on your staff turnover), you will have to pack the table occasionally to get rid of the deleted IDs, but it is not likely to be time-critical.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
It sounds like they are using the ID as sort of an extension number which would facilitate the need to re-use the ID.

I would ge with the suggestion to blank out the data and reuse the old record.

Ed
 
I couldn't blank out the record, because it was set to not accept blank values. What I did was append 5 random numbers together and stuck them in the emp id field.

Thank you for your helping.
 
I guess that I was not implying that you Blank the Employee ID field since that is the value that you want to re-use.

Instead I was suggesting that you blank all of the other fields so that they could then be re-populated with the new employee's data. You could do this as part of a PURGE utility which removed old, employees.

Then when you needed to find an un-used Employee ID, you could merely search (SEEK??) to find an EMPTY(Name).

Good Luck,
JRB-Bldr


 
Just one caveat to that approach - if the employee ID relates to data in other tables you would need to blank those also, and that means losing your history on the former employee.

Regards,
Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top