xHarbour Reference Documentation > Command Reference xHarbour Developers Network  

UPDATE

Updates records in the current work area from a second work area.

Syntax

UPDATE FROM <cAlias> ON <expression> ;
    [RANDOM] ;
    REPLACE <fieldName1> WITH <value1> ;
          [,<fieldNameN> WITH <valueN> ]

Arguments

FROM <cAlias>
This is the alias name of the second work area used update the current work area. It can be specified as a literal alias name or a character expression enclosed in parentheses.
ON <expression>
This is an expression whose value is searched in the second work area to find the records for updating the current work area.
RANDOM
The option allows records in the FROM work area to be in any order. If this option is specified, the current work area must be indexed on <expression>.
REPLACE <fieldName>
This is the symbolic name of a field variable in the current work area to assign a new value to.
WITH <value>
The result of of <value> is assigned to <fieldName>. Note that <value> must yield a value of the same data type as the field valriable. Memo fields must be assigned values of data type Character.

Description

The UPDATE command replaces fields in the current work area with values from a second work area based on <expression>. An update occurs when <expression> provides the same value in both work areas. This requires the current work area be indexed on <expression> and that no multiple key values exist in this index. When there are multiple records with the same key value, only the first record with this key value is updated. The FROM work area, however, can have duplicate key values.

If RANDOM is not specified both work areas must be indexed on <expression>. If RANDOM is specified, only the current work area needs to be indexed on <expression>.

In a multi-user application in network operation, the file in the current work area must be exclusively open or a file lock with FLock() must be applied.

Records marked for deletion are not processed in either work area when SET DELETED is set to ON.

Info

See also:AVERAGE, DbEval(), INDEX, OrdCreate(), REPLACE, SORT, SUM, TOTAL
Category: Database commands
Source:rdd\dbcmd.c
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe