Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace vs Update
Message
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00408377
Message ID:
00408594
Views:
11
In addition, the "IN" option is just to specify the table/alias name without forcing you to SELECT before REPLACE which is quite smart. And so, the "IN" has nothing to do with LOCKing issue.

As with regards to Aliased fields:
If I have two opened tables a & b, I could do REPLACES on both tables in just single REPLACE command something like REPLACE a.field WITH blah..blah.., b.field IN a

>Chapter 17 of MS VFP Programmer's Guide. It's in the MSDN Help file too.
>In my best capacity to understand and based on my observation:
>1. REPLACE ALL fields WITH blah..blah... FOR expression IN tablename - locks entire table.
>2. REPLACE fields WITH blah..blah... FOR expression IN tablename - locks all records that meets the FOR clause.
>3. REPLACE fields WITH blah..blah.. IN tablename - locks single record only.
>
>Buffering 4 & 5 locks entire table with TABLEUPDATE() command
>Buffering 2 & 3 locks updated records only with TABLEUPDATE() command
>
>>>>From the Hacker's Guide: "The help hints and our tests confirm that REPLACE is generally faster than UPDATE. In exclusive mode, the differences are small, but with shared tables, we see tremendous differences. The reason for the difference is that UPDATE uses record locking while REPLACE locks the entire table. There may be cases where you can't lock the table, so UPDATE's behavior can save your skin in spite of its performance consequences".

>>>
>>>Hello Sylv!
>>>
>>>For your reference:
>>>
>>>Command           Scope of Lock
>>>----------------  ---------------------------------------------------
>>>REPLACE           Current record and all records from aliased fields
>>>REPLACE NEXT 1    Current record and all records from aliased fields
>>>REPLACE RECORD n  Record n and all records from aliased fields
>>>REPLACE of more
>>>than one record   Entire table and all files from aliased fields
>>>TABLEUPDATE( )    Depends on buffering
>>>UPDATE            Entire table
>>>UPDATESQL      Entire table
>>>
>>>
>>>>Can somebody tell me the difference between using "replace" and "update"?
>>>>>
>>>>>I'm using regular VFP database (not MSSQL), I don't use views and usually, I open the tables with buffering mode 5.
>>>>>
>>>>>I usually use "replace" and never got problem but I've seen other programmers using "update" and I would like to understand the difference, advantages and pitfalls of both commands.
>>
>>Where did you get this info, Jess? Is my understanding rigt, that
>>replace field1 with val1, field2 with val2 would lock one record, while
>>replace table1.field1 with val1, table1.field2 with val2 the whole table1?
>>What about replace ... in table1?
>>
>>I've never paid attention to this before, but it could be important.
>>TIA
JESS S. BANAGA
Project Leader - SDD division
...shifting from VFP to C#.Net

CHARISMA simply means: "Be more concerned about making others feel good about themselves than you are in making them feel good about you."
Previous
Reply
Map
View

Click here to load this message in the networking platform