Replace
REPLACE puts data in fields. It's the table counterpart to STORE or =, which put data in variables, but have no effect on fields. (We can't tell you how often we've written code that uses = with fields and then had to figure out what was wrong with it.)
Usage |
REPLACE uField1 WITH eExpr1 [ ADDITIVE ] [, uField2 WITH eExpr2 [ ADDITIVE ] [, ... ] ] [ Scope ] [ FOR lForExpression ] [ WHILE lWhileExpression ] [ IN cAlias | nWorkArea ] [ NOOPTIMIZE ] |
Example |
* Two ways to update a memo field REPLACE notes WITH notes+chr(13)+ ; dtoc(date())+" Called - line was busy" REPLACE notes WITH chr(13)+dtoc(date())+ ; "Called - line was busy" ADDITIVE * Suppose the area code for a bunch of phone numbers * changes. You need to update those records. * Assume you've stored the exchanges that are changing * in a table, EXCHANGES, with one field, Exchange, and * a tag on that field. * The old area code is stored in cOldCode. * The new area code is stored in cNewCode. USE PhoneList USE Exchanges IN 0 ORDER Exchange SET RELATION TO LEFT(Phone,3) INTO Exchanges REPLACE AreaCode WITH cNewCode ; FOR AreaCode=cOldCode ; AND FOUND("Exchanges") |
See Also |
Begin Transaction, Insert-SQL, Set Optimize, Store, Update-SQL |