Difference between revisions of "UPDATE"

From Recital Documentation Wiki
Jump to: navigation, search
 
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=UPDATE=
 
 
 
==Class==
 
Fields and Records
 
 
 
 
==Purpose==
 
==Purpose==
 
Update the contents of the active table with data from another table
 
Update the contents of the active table with data from another table
Line 19: Line 12:
  
 
==See Also==
 
==See Also==
[[AVERAGE]], [[COUNT]], [[SUM]], [[TOTAL]], [[SET FILTER]], [[SET RELATION]]
+
[[AVERAGE]], [[COUNT]], [[SET FILTER]], [[SET RELATION]], [[SUM]], [[TOTAL]]
  
  
Line 30: Line 23:
 
==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
replace balance with balance + new->balance
+
use newpatrons alias new
 +
select a
 +
use patrons index names, events, dates
 +
update on name from new;
 +
  replace balance with balance + new->balance
 
</code>
 
</code>
  
  
 
==Products==
 
==Products==
Recital Database Server, Recital Mirage Server, Recital Terminal Developer
+
Recital Server, Recital  
 
[[Category:Documentation]]
 
[[Category:Documentation]]
 
[[Category:Commands]]
 
[[Category:Commands]]
 +
[[Category:Table Basics]]
 +
[[Category:Table Basics Commands]]

Latest revision as of 16:27, 25 November 2009

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 Server, Recital