Difference between revisions of "UPDATE"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 30: Line 30:
 
==Example==
 
==Example==
 
<code lang="recital">
 
<code lang="recital">
select buse newpatrons alias newselect ause patrons index names, events, datesupdate on name from new;
+
select b
 +
use newpatrons alias new
 +
select a
 +
use patrons index names, events, dates
 +
update on name from new;
 
replace balance with balance + new->balance
 
replace balance with balance + new->balance
 
</code>
 
</code>

Revision as of 10:32, 16 March 2009

UPDATE

Class

Fields and Records


Purpose

Update the contents of the active table with data from another table


Syntax

UPDATE ON <key expression> FROM <workarea | alias>

REPLACE <field> WITH <exp> [,<field> WITH <exp>...]

[RANDOM]


See Also

AVERAGE, COUNT, SUM, TOTAL, SET FILTER, SET RELATION


Description

The UPDATE command updates fields in the active table based upon data from another table. The <key expression> must exist in both tables. The active table must be indexed on the specified <key expression> unless the RANDOM keyword is specified. The FROM table can be in any order. If a FILTER <condition> is active in the FROM workarea, then only those records which satisfy the <condition> are processed. If SET DELETED is ON, then records which are marked for deletion in the FROM workarea are not processed.

It is strongly recommended that the active table be indexed on the <key expression>, otherwise ALL records satisfying the <key expression> values in the FROM file are updated in the active table, which can be a lengthy process. The UPDATE command is primarily used to update a 'master' file from records held in a 'transaction' file.


Example

select b
use newpatrons alias new
select a
use patrons index names, events, dates
update on name from new;
replace balance with balance + new->balance


Products

Recital Database Server, Recital Mirage Server, Recital Terminal Developer