Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a part number
Message
From
30/01/1997 16:35:39
 
 
To
30/01/1997 15:20:45
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00018858
Message ID:
00018881
Views:
37
>>I am a little bit green in some areas. This is only my 2ed application :-) On the first one is was a geographic location that the user supplied. Any suggestions? thanks for your patients
>
>Try something like this
>
>* Get the next unique key
>LOCAL lcAlias,lnOldRec,lnDernier,lnSelect
>lcAlias=ALIAS()
>lnSelect=SELECT()
>SELECT TABLE
>lnOldRec=SAVEREC()
>SEEK lcAlias ORDER ALIAS
>lnDernier=0
>DO WHILE NOT RLOCK()
>ENDDO
>REPLACE CLE WITH CLE+1
>UNLOCK
>lnDernier=CLE
>RESTREC(lnOldRec)
>SELECT (lnSelect)
>RETURN lnDernier
>
>You may want to create TABLE.DBF, which contains the tables used in your application. At least, one field, CLE, is used to keep the current last unique id.

If the table is part of a DBC you can use a stored procedure for default value of that field. The default value procedure is a function call like GETNEXTID(). The GETNEXTID() function can look like the sample code above. Now anytime a record is appended to this table it will get a new id.
David Lepus
Previous
Reply
Map
View

Click here to load this message in the networking platform