Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Re-numbering problem
Message
De
23/02/2009 23:11:47
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01383631
Message ID:
01383665
Vues:
45
> Well, I needed to change the sequence number
> (it's an integer field in my table).

It is difficult to read between the lines. You have not indicated, is it a simple Integer field or Integer(Autoinc).

> So, for each FK I needed a sequence from 1 to the number
> of records for this FK. I also needed to figure out
> how would I change the number to not mess up the
> original numbering (at the end, I didn't take this
> into consideration, so I may have some surprises tomorrow).

So, there can be several records with equal FK and you must create a new value for FK that is equal to maximum+1.
At first, find a number of records for this FK. For instance :

SELECT MyTable
COUNT TO FKRecords FOR FK=18

* Then, make sure it doesn't "mess up the original numbering".

CALCULATE MAX(FK) TO FKMax IN MyTable
IF FKMax>=FKRecords
FKRecords=FKMax+1
ELSE
FKRecords=FKRecords+1
ENDIF

You'll get a next available value in FKRecords without any mess-up.

> Anyway, while you were sleeping I already implemented
> quite simple algorithm and ran it in production.
> So, you may go to sleep or are you starting your
> work day already? If yes, all the best to you and good luck!

Hm, "if woman mistakens, I must apologize". :)
P.S. I'm not sleeping, 'cos it's 14:10 on my watches.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform