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:
00408628
Views:
13
>Jess, does it make a difference between these two syntaxes:
>replace fields with blah blah... in TableName (only 1 record)
>replace TableName.fields with blah.. blah... in TableName?

None - functionality wise. The only difference is that the second one is just what they call "aliased/tabled field." The "IN" clause is the primary reference table for VFP to look with. Without it, VFP will look for the currently SELECTED table/workarea, otherwise, error.


>>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