Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Replace not working!! ahhhhhhh!!!!
Message
De
06/12/2000 11:33:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
06/12/2000 10:58:04
Erin Eby
Mission Critical Software
Gainesville, Floride, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00449956
Message ID:
00449982
Vues:
8
>:) Good morning all. I have a question...I have a field in a table that is numeric, and is incremented by 1 for each record. The table is a list of items. Each item must have a unique number. I would like to run a SCAN statement to update the entire table (3000 records) with an auto-incrementing number for each record. here's my code:
>
>LOCAL ln_cnt
>ln_cnt = 100001
>SELECT 0
>USE tablename AGAIN ALIAS x_tablename
>SELECT item, uniqnum from x_tablename order by uniqnum into cursor c_items
>
>SELECT c_items
>GO TOP
>
>SCAN
>
> SELECT x_tablename
> LOCATE FOR ;
> item = c_items.item
> IF FOUND()
> REPLACE x_tablename.uniqnum WITH ln_cnt
> ln_cnt = ln_cnt + 1
> ELSE
> MESSAGEBOX("Item not found.")
> ENDIF
>ENDSCAN
>******************************************8
>when it gets done...each record should have a unique number beginning with 100001 (in theory :). however, when i go back to check my table, it has only updated the first record, and nothing else has happened. i run the entire code again, and this time it updates 2 records. i run the entire code again, and it updates another record, however, it duplicates the number. so i have 3 records updated with numbers of 100001, 100002, 100003. and the rest of the table is the same. any clues??? TIA

select tablename
replace all uniqnum with 100000+recno()

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform