Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Conflicts
Message
From
08/03/2002 00:03:45
 
 
To
07/03/2002 23:25:04
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00628329
Message ID:
00630026
Views:
18
Ric,
I would like to add & correct to what you have written below -

* Insert does not require an exclusive access on the table for adding a record.

* Insert without 'After' or 'Before' clause will obviously append a record to the end of the table.

* I would not recommend using 'BEFORE' or 'AFTER' clause bcoz it has a overhead time which you have mentioned. But u can use indexes to view data in your desired way or u can also create views to view only a sub-set of data.

* Open indexes or compound index filex (.CDX) automatically get auto updated once any addition /deletion or modification is done on the table. But if a table is bulky than having many indexes will be a performance issue.

* Insert & Append will lock the table header to add a record in the DBF. So if u do not want to see the msg 'Attempting to lock ..pess ESC to cancel' make sure your application or your .PRG does not issue or let remain, FLOCK() on the table for a long time bcoz other users will get the msg.

* Locking of the table is not recommended until you have enough reasons for doing so but even if you do remove flock() immediately after your processing is over.

* if you are using BUFFERING, INSERTS & APPEND BLANK will work fine on a buffered table. In buffering mode you do not have to worry about locking records or locking tables. VFP automatically set locks whien u give TABLEUPDATE(), depending on type of buffering you have selected (OPTIMISTIC/PESSIMISTIC ROW/TABLE)

Sanjay.



>Steven,
>
>Well, to begin with - INSERT is a very bad idea from a time when it used to be a good idea. You will get locks and freezes because INSERT does many interesting things...
>
>If you INSERT:
>
>1) it requires exlucsive access.
>2) by itself, automatcally inserts the record physically after the current record.
>3) with BEFORE - it means all of the records AFTER your insert have to get physically REWRITTEN.
>4) if the table has ANY indexes open, guess what, the insert goes to the EOF() to insert, regardless of the index (so why insert? why not append?)
>5) Here is the cruncher, you cannot insert into buffered tables, tables with rules, etc... (see one above)....
>
>Now, even if there is no delay sometime; tis okay. But, count up all of the Reads, and writes required with the INSERT command, and then figure all of the Header locks, file locks, and record locks automatically happening and you will have a high number of collisions amongst your users.
>
>HTH
>
>Ric
>
>
>>I have a multi-user engineering drawing app. I am having some trouble with the app locking up. I seems to happen to just one of the tables. When a user begins to work on a particular drawing number the code first serches this table to see if the number exists. If it does the record is updated with current info. If the record does not exist I do an Insert Into command to add the record to the table. I have gone into the table manually while others were using the app and tried to append a record to the table. Sometimes the record will append fine. At other times I will get a message in the status bar 'Attempting to lock... Press ESC to cancel.' If I press cancel I get a message that record is in use by another user, which I do not see how that is possible. If I don't hit the ESC key and wait a while the record will somtimes go ahead and append, however the time it takes is much longer that the code would take for another user to add a record.
Sanjay Dhiraj Patel

MCSE, MCDBA

Net2Biz (Thailand)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform