Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transaction x LOCK/UNLOCK
Message
From
30/03/2006 12:13:57
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01109212
Message ID:
01109231
Views:
28
Hello Terry
>Fred
>
>1) How can you assume that the LOCK() has been successful? Someone else may have locked it.
>
>Better iS:
>
>If LOCK('mytable')
> insert into mytable ...
> Unlock
>EndIf
>

I already use an IF command to verify if the table is locked, this rotine is OK.



>2) Is it necessary to lock the whole table anyway? I believe that Lock only locks the file header when inserting anyway. Do you want to prevent all other users update access to the already existing data while you're adding new?
>
>3) your codse suggests that you only want to insert 1 record anyway. Xactions are used mainly to ensure ALL critical updates succeed or none. Surely here TableUpdate() for buffered data will suffice to decide on success or failure of the insert?

I wonder that BEGIN/END TRANSACTION do the same thing as LOCK/UNLOCK, so I don't need BEGIN a transaction and LOCK the file at the same time. Just Begining a transaction is my file safe to insert data under network?

I have many users inserting data at the same file.

>
>HTH
>
>Terry
>
>>Hello *.*
>>
>>look at these scenarios:
>>
>>1) I´m using free tables under a network, when I insert data I do it:
>>
>>
>>select mytable
>>   lock('mytable')
>>insert into mytable ...
>>unlock
>>
>>It´s all right.
>>
>>2) I´m using DBF Tables in to DBC container, so I do it:
>>
>>BEGIN TRANSACTION
>>  SELECT MYTABLE
>>  LOCK('MYTABLE')
>>    INSERT INTO MYTABLE ...
>>  UNLOCK
>>END TRANSACTION
>>
>>
>>The question is: Is it really necessary LOCK the table when I use BEGIN/END TRANSACTION ?
>>
>>Thanks in advance.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform