Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Additon in character type data
Message
 
À
28/06/2006 15:05:36
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 6 SP5
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01132547
Message ID:
01132817
Vues:
13
>Dear Experts
>
>Field1 of Table1 has character type date, but digits.
>In Field2, I want to replace data as under
>
>801--------801
>803--------802
>807--------803
>809--------804
>
>902--------901
>905--------902
>906--------903
>908--------904
>
>
>In second column data is written by 1 digit addition but the first digit remain same.
>
>Please help

I hope you have order by Field1, if so:
SELECT MyTable
SET ORDER TO OrderByFirstField
GO TOP
lcFirstLeft   = LEFT(Field1,1)
lcNextReplace = 0
SCAN
   IF NOT LEFT(Field1,1) == m.lcFirstLeft
      lcFirstLeft   = LEFT(Field1,1)
      lcNextReplace = 0
   ENDIF
   m.lcNextReplace = m.lcNextReplace + 1
   REPLACE Field2 WITH INT(VAL(lcFirstLeft+PADL(m.lcNextReplace,2,[0])))
ENDSCAN
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform