Auto-increment field copy 
Author Message
 Auto-increment field copy

Hi

I'm trying to copy a table which has an auto-increment field has the
first key using a batch move.  The copy I get is the same file in which
the keys have been reset to 1.  For example, my source file contains
records with those keys:

10  -  11  -  12  -  16

What I get in the copy is

1  -  2  -  3  -  4

which of course is unacceptable.  What's the best way to fix that
problem?

Any and all help is greatly appreciated.

Thanx

Marc Charron
Unicate Network Inc.



Wed, 18 Jun 1902 08:00:00 GMT  
 Auto-increment field copy

Quote:
> Hi

> I'm trying to copy a table which has an auto-increment field has the
> first key using a batch move.  The copy I get is the same file in which
> the keys have been reset to 1.  For example, my source file contains
> records with those keys:

> 10  -  11  -  12  -  16

> What I get in the copy is

> 1  -  2  -  3  -  4

> which of course is unacceptable.  What's the best way to fix that
> problem?

> Any and all help is greatly appreciated.

2 things.

if the destination table is a new table, then the autoincrement field is
going to start at 1. on each insert of new data, the autoincrement field is
gonna up by one. if you are using this particular table with referential
integrity, things are going to go to hell in a big way because the autoinc
field is going to do its own thing whether you like it or not.

an easier option would be to make the field in the destination table an
integer field instead of a autoinc field and then batchmove the info over
that way, keeping the original number sequence as in your source table.  

you might even consider leaving it as an integer and coding your increments
in delphi and keeping a tab on the value with a 'counters' table.

Personally I have found I DO NOT like the autoincrement field due to the
excessive amounts of fiddling around with it, AND the batchmove thing
wreaks havoc with it too.

good luck!



Wed, 18 Jun 1902 08:00:00 GMT  
 Auto-increment field copy


Quote:
>Hi

>I'm trying to copy a table which has an auto-increment field has the
>first key using a batch move.  The copy I get is the same file in which
>the keys have been reset to 1.  For example, my source file contains
>records with those keys:

>10  -  11  -  12  -  16

>What I get in the copy is

>1  -  2  -  3  -  4

>which of course is unacceptable.  What's the best way to fix that
>problem?

>Any and all help is greatly appreciated.

>Thanx

>Marc Charron
>Unicate Network Inc.

Change your field type.  The autoincrement field will always number the
fields in the order you add the records.  You may have to change the field
type from autoincrement in your second table to longint(?).


Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Auto increment field

2. Master-detail and auto-increment fields

3. Need help defining auto-incrementing field using TTable.Create

4. Auto Increment Fields and Master Details Relationship

5. Question about auto increment field

6. MS Access Auto incrementing Key fields

7. Delphi 2 SQL Server 6 problem with identifier (auto-increment) fields

8. Auto-increment fields - Should I Use Them?

9. Obtaining value of Paradox's Auto-Incremented Field Type

10. How to reset auto- increment Fields

11. Auto-increment fields

12. Delphi3-auto-increment fields

 

 
Powered by phpBB® Forum Software