Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
INSERT-SQL
Message
 
 
À
16/08/1997 07:08:39
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00044588
Message ID:
00045115
Vues:
37
>>Curiosity got the best of me, and I had to look this up. In Jeb Long's VFP 3 Developer's Guide is a chart of how commands are affected by autolocking
>>(pp 1269-1270). *Append From* locks the table , Append From Array, Append Blank and Insert (SQL) all lock the header only. Granted, both effectively lock the table and prevent new attemts by users to lock either the table or the header (but should not prevent new attempts at record locking). But, if another user on the system has an existing record locked for editing, you could still use the Insert SQL to add records to the table without affecting the other user(s) who have only record locks in place. You could not do this with *Append From*. So in a heavily used multi-user system, Insert SQL is the way to go (IMHO) to prevent some contention.
>>
>>Of course, much of this has been alleviated by table buffering. And, VFP does very well managing automatic file and record locking when used with buffering.
>
>I have read pretty much the same thing in the VFP documentation. But I haven't been able to find an example of how to use INSERT-SQL to insert multiple records. Can someone tell me how to do this?
>
>TIA
>Bill Chadbourne
>wchad@ime.net

To insert multiple records into a table using Insert SQL requires the data to be in an array. The first element in row 1 of the array is inserted into the first field of the target table, the 2nd elem goes in field 2, etc... To try this out, open a table, copy its structure to a dummy table, then copy a few rows to an array:

use MyTable
copy structure to TestTable
copy next 5 to array dummy
insert into TestTable from array dummy

All five records will be inserted into the new table. This only locks the table header. It is true only 1 person can be APPENDing FROM at time because that locks the entire table. The table can not be locked if any another user has at least 1 record locked in the table. This is the key difference between only locking the header and locking the table. When only the header is locked other users can still have records locked (i.e., editing can still be done). Since INSERT SQL is faster, you have less contention.

In the example above, the array can also be created on the fly during data entry of a new record by creating your own array and populating the elements yourself through code.
Mark McCasland
Midlothian, TX USA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform