Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simple field rule???
Message
De
29/09/2005 16:23:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
29/09/2005 13:39:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01054488
Message ID:
01054669
Vues:
22
>Yes,
>
>That would be great I only found this site today I will be happy for any assistance.
>
>Sincerely,
>
>Fred Watt

OK, then, here goes. I suggest storing the function in the database stored procedures. You will also need to create the table (included it in the database, if it needs to participate in transactions).

Regards,

Hilmar.
**********************************************************************
FUNCTION SerialNumber(tcSequence)
	* Get serial number. Used mainly to generate primary keys.
	* The easiest way to achieve this is to call this function from a fields default value.
	* Example: default value for primary key "Client" of table "Client" = SerialNumber("Client")
	* This function accesses table SerialNumber. Fields: Sequence C(30), NextNum I.
	tcSequence = lower(tcSequence)
	local lnSelect
	lnSelect = select()
	if used("serialnumber")
		select serialnumber
	else
		select 0
		use serialnumber
	endif
	set order to "sequence"
	seek padr(tcSequence, len(sequence))
	if not found()
		append blank
		replace sequence with tcSequence, nextnum with 1
	endif
	local lnReturnValue
	if lock()
		lnReturnValue = nextnum
		replace nextnum with nextnum + 1
	else
		lnReturnValue = -1
	endif
	unlock
	select (lnSelect)
	return lnReturnValue
ENDFUNC
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform