Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- The Guide To Clipper - <b>update</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
UPDATE


Syntax:     UPDATE ON <key exp> FROM <alias>/(<expC>) REPLACE <field1>
            WITH <exp1> [,<field2> WITH <exp2>]... [RANDOM]

Purpose:    To update the current database file from another database
            file based on a one-to-one or one-to-many relation.

Arguments:  <key exp> is an expression used that defines matching
            records in the FROM work area.

            <alias> is the alias of the FROM work area used to
            update records in the current work area.

            <field1...fieldN> are the fields in the current work
            area to replace with new values.

            <exp1...expN> identifies the values to replace into the
            current fields.  Fields from the FROM work area must be
            referenced with the alias of the respective work area.

Option:     Random: The RANDOM clause causes the entire FROM
            database file to be read allowing the FROM database file to
            be in any order.  If this option is specified, the current
            database file must be indexed on the <key exp>.

Usage:      UPDATE matches records in the current work area using the
            key expression as the argument of a lookup into the FROM
            work area.  To obtain an accurate UPDATE, both database
            files must be sorted or indexed on the key expression.  If
            the FROM database file is not sorted or indexed, use the
            RANDOM clause.

            Relations between work areas: UPDATE supports both
            one-to-one and one-to-many relations between the current and
            the FROM work areas.  It does not, however, support
            many-to-many or many-to-one relations.  All FROM records
            matching the <key exp> UPDATE only the first instance of the
            matching current record.

            Types of replacement: When you UPDATE, the REPLACE
            expression determines the type of UPDATE made to a current
            field.  If the UPDATE to the field adds to the current
            field, the formulation is:

            REPLACE <current field> WITH <current field> + <expN>

            Likewise, if the UPDATE subtracts from the current field,
            the formulation is:

            REPLACE <current field> WITH <current field> - <expN>

            Deleted records: When DELETED is ON, all current records
            are UPDATEd including deleted ones.  Deleted FROM records,
            however, are ignored.

Network:    In order to UPDATE in a network environment, the current
            database file must be locked with FLOCK() or USEed
            EXCLUSIVEly.  The FROM file may either be USEd EXCLUSIVEly
            or shared.

Library:    CLIPPER.LIB


----------------------------------- Examples -------------------------------

   This example UPDATEs a Customers database file with outstanding
   invoice amounts:

   USE Customers INDEX Customers
   SELECT B
   USE Invoices
   SELECT Customers

   UPDATE FROM Invoices RANDOM;
          ON Last;
          REPLACE Owed WITH;
          Owed + Invoices->Amount


See Also: REPLACE SET UNIQUE

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson