Deleting Records With Primary Keys

Deleting Records With Primary Keys

Post by Tharini » Fri, 31 Jan 1997 04:00:00



Hi there...
I am working on a project in VFP5.0
I have a routine to delete records from a table, 'Company Table'

My Company codes are primary index keys.
The problem is that, once I delete a company code,  e.g. ' 01'  I am
unable to  add a new record with the same code ' 01' .
I don't pack the deleted records.
My set deleted is on.

Thanks..

 
 
 

Deleting Records With Primary Keys

Post by Ian Simcoc » Fri, 31 Jan 1997 04:00:00



> I am working on a project in VFP5.0
> I have a routine to delete records from a table, 'Company Table'
> My Company codes are primary index keys.
> The problem is that, once I delete a company code,  e.g. ' 01'  I am
> unable to  add a new record with the same code ' 01' .

That's the way it's supposed to work. You can't add another record with
the same primary key. While the record may be deleted it is still in the
table (since you can recall it) and thus won't allow a duplicate ID.

Normaly you wouldn't reuse an ID number even if you'd deleted the
original record, though that is a matter of preference.

Ciao for now,
   Ian Simcock.

 
 
 

Deleting Records With Primary Keys

Post by Esa Aj » Fri, 31 Jan 1997 04:00:00


Use filter NOT DELETED() in primary key.
--
Esa Ajo
Micromentors Ltd
Sennantie 12
FI-11130 Riihimaki
Finland



Quote:> Hi there...
> I am working on a project in VFP5.0
> I have a routine to delete records from a table, 'Company Table'

> My Company codes are primary index keys.
> The problem is that, once I delete a company code,  e.g. ' 01'  I am
> unable to  add a new record with the same code ' 01' .
> I don't pack the deleted records.
> My set deleted is on.

> Thanks..

 
 
 

Deleting Records With Primary Keys

Post by Yuri Migue » Fri, 31 Jan 1997 04:00:00



> Hi there...
> I am working on a project in VFP5.0
> I have a routine to delete records from a table, 'Company Table'

> My Company codes are primary index keys.
> The problem is that, once I delete a company code,  e.g. ' 01'  I am
> unable to  add a new record with the same code ' 01' .
> I don't pack the deleted records.
> My set deleted is on.

> Thanks..

If you don't want to pack the database, and you will not use again
the codes you delete, you can replace the code with 'xx' or '**'
so you can add another with the same code.

Yuri Miguel

 
 
 

Deleting Records With Primary Keys

Post by Richard Hundhause » Fri, 31 Jan 1997 04:00:00


Two solutions as I see it ...

1. Keep your "Next Company Code" variable in a SYSTEM.DBF, or other table
    which keeps track of the next avaiable number, always incrementing and
never
    starting over.

2.  If you don't want to do this and you want to GO BOTTOM and find the
last
     customer number used (which works good on a single-user installation),
then
     you just need to SET DELETED OFF while going to the bottom.  Then, as
soon
     as you get the last customer number, SET DELETED ON and you've got it.

Either way, you won't need to PACK your tables, although a PACK now and
then isn't a bad thing, is it?

HTH

-Rich



Quote:> Hi there...
> I am working on a project in VFP5.0
> I have a routine to delete records from a table, 'Company Table'

> My Company codes are primary index keys.
> The problem is that, once I delete a company code,  e.g. ' 01'  I am
> unable to  add a new record with the same code ' 01' .
> I don't pack the deleted records.
> My set deleted is on.

> Thanks..