Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does insert command lock a record
Message
De
21/05/2015 08:11:31
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01620017
Message ID:
01620038
Vues:
84
>Hi all,
>
>I'm having a problem with an application sometimes confusing 2 records in a table. happens about once a week. Anyway I'm going over the code and I use scatter...append blank...gather in some places. I'm wondering if I change this to an insert command does the insert command automatically lock either the table or record while inserting. I'm trying to find out online but nothing explicit is popping up. It is VFP code and a VFP table.

I guess VFP indeed locks prior to inserting a new record. Not the entire table, but 'record 0', which is a virtual recordnumber, also called the headerrecord. And after the insert it is released for use by others who want to insert. If an insert requires a value that must be unique - let's say a unique identifier - then it's wise to lock record 0 by hand beforehand.
*	Lock the header before inserting a new record.
*	And have some patience because someone else may be trying an insert at the same time.
do while not rlock( '0', alias() )
enddo

* Create the unique value(s) here, e.g. a unique record identifier.
* Do your insert here.

*	Unlock the header record.
unlock record 0 in ( alias() )
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform