Difference between revisions of "UPDATE"

From Recital Documentation Wiki
Jump to: navigation, search
Line 1: Line 1:
 
==Class==
 
==Class==
Fields and Records
+
Table Basics
  
  
Line 40: Line 40:
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
[[Category:Table Basics]]
 +
[[Category:Table Basics Commands]]

Revision as of 10:49, 4 June 2009

Class

Table Basics


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, SET FILTER, SET RELATION, SUM, TOTAL


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