C5_UPDATE

UPDATE
 Update current database file from another database file
------------------------------------------------------------------------------
 Syntax

     UPDATE FROM <xcAlias>
        ON <expKey> [RANDOM]
        REPLACE <idField> WITH <exp>
        [, <idField2> WITH    <exp2>...]

 Arguments

     FROM <xcAlias> specifies the alias of the work area used to update
     records in the current work area.  This argument may be specified either
     as a literal file name or as a character expression enclosed in
     parentheses.

     ON <expKey> specifies the expression that defines matching records
     in the FROM work area.

     REPLACE <idField> specifies a field in the current work area to
     replace with a new value.

     WITH <exp> specifies the value to replace into the current field.
     You must reference any field contained in the FROM work area with the
     correct alias.

     RANDOM allows records in the FROM database file to be in any order.
     If this option is specified, the current database file must be indexed
     on <expKey>.

 Description

     UPDATE is a database command that replaces fields in the current work
     area with values from another work area based on the specified key
     expression.  UPDATE is designed to update only current work area records
     based on a one-to-one or one-to-many relation with the FROM work area.
     This means that UPDATE can only update records in the current work area
     with unique key values.  When there is more than one instance of a key
     value, only the first record with the key value is updated.  The FROM
     work area, however, can have duplicate key values.

     There are two formulations of the command depending on whether the FROM
     work area records are sorted or indexed on <expKey> or not.  If RANDOM
     is not specified, both the current work area and the FROM work area must
     be indexed or sorted in <expKey> order.  If RANDOM is specified, the
     current work area must be indexed by <expKey>, but the FROM work area
     records can be in any order.

     To use UPDATE in a network environment, the current database file must
     be locked with FLOCK() or USEed EXCLUSIVEly.  The FROM database file may
     be used in any mode.  Refer to the "Network Programming" chapter in the
     Programming and Utilities Guide for more information.

 Notes

     .  Deleted records: If DELETED is OFF, deleted records in both
        source files are processed.  Records in the file being updated retain
        their deleted status and are not affected by the deleted status of
        records in the FROM file.  If DELETED is ON, however, no deleted
        records are processed from either source file.

 Examples

     .  This example UPDATEs the Customer database file with
        outstanding invoice amounts:

        USE Invoices NEW
        USE Customer INDEX Customer NEW
        UPDATE FROM Invoices ON Last;
           REPLACE Owed WITH Owed + Invoices->Amount RANDOM

 Files   Library is CLIPPER.LIB.

See Also: DBCREATEIND() INDEX JOIN REPLACE SET UNIQUESORT

 

Advertisements

2 responses to “C5_UPDATE

  1. Pingback: DB Commands | Viva Clipper !

  2. Pingback: C5 Commands | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.