Difference between revisions of "GATHER"
Yvonne.milne (Talk | contribs) |
|||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Replace fields with elements from an array or series of memory variables | Replace fields with elements from an array or series of memory variables | ||
− | |||
==Syntax== | ==Syntax== | ||
− | GATHER FROM <array> | MEMVAR | + | GATHER FROM <array> | MEMVAR |
+ | [FIELDS <field list> | FIELDS LIKE <skeleton> | FIELDS EXCEPT <skeleton>] | ||
+ | |||
+ | [MEMO] | ||
==See Also== | ==See Also== | ||
− | + | [[ADEL()]], [[ADIR()]], [[AFIELDS()]], [[AFILL()]], [[AINS()]], [[ALEN()]], [[ARRAY()]], [[ASCAN()]], [[ASORT()]], [[COPY TO ARRAY]], [[IN_ARRAY()]], [[IS_ARRAY()]], [[LOCAL]], [[PRIVATE]], [[PUBLIC]], [[SCATTER]] | |
− | + | ||
==Description== | ==Description== | ||
The GATHER command replaces fields in the current record with elements from the specified array <array> or, if the MEMVAR keyword is used, from a series of memory variables with the same names as the fields. If the current table is shared, then automatic record locking is performed for the update operation. The data types of the array elements or memory variables and corresponding fields must be compatible. If the array has fewer elements than the number of fields in the record, then fields are modified only up to the number of elements specified. If no matching memory variable is found for a field, the field is unchanged. | The GATHER command replaces fields in the current record with elements from the specified array <array> or, if the MEMVAR keyword is used, from a series of memory variables with the same names as the fields. If the current table is shared, then automatic record locking is performed for the update operation. The data types of the array elements or memory variables and corresponding fields must be compatible. If the array has fewer elements than the number of fields in the record, then fields are modified only up to the number of elements specified. If no matching memory variable is found for a field, the field is unchanged. | ||
− | ====FIELDS <field list>==== | + | ====FIELDS <field list> | FIELDS LIKE <skeleton> | FIELDS EXCEPT <skeleton>==== |
− | The optional FIELDS <field list> can be used to restrict the fields updated to those in the comma separated <field list>. | + | The optional FIELDS <field list> can be used to restrict the fields updated to those in the comma separated <field list> or those matching the LIKE <skeleton> or those not matching the EXCEPT <skeleton>. |
====MEMO==== | ====MEMO==== | ||
Line 21: | Line 22: | ||
If SET LOCKTYPE TO OPTIMISTIC is active, an attempt to use the GATHER command on a record that has been modified since it was last read will generate an error. | If SET LOCKTYPE TO OPTIMISTIC is active, an attempt to use the GATHER command on a record that has been modified since it was last read will generate an error. | ||
− | |||
==Example== | ==Example== | ||
Line 29: | Line 29: | ||
scatter fields last_name, first_name to table_1 | scatter fields last_name, first_name to table_1 | ||
append blank | append blank | ||
− | gather fields last_name, first_name | + | gather from table_1 fields last_name, first_name |
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:Commands]] | [[Category:Commands]] | ||
− | [[Category: | + | [[Category:Declaring Variables and Arrays]] |
− | [[Category: | + | [[Category:NoSQL Commands]] |
− | + |
Latest revision as of 11:34, 22 May 2014
Contents
Purpose
Replace fields with elements from an array or series of memory variables
Syntax
GATHER FROM <array> | MEMVAR
[FIELDS <field list> | FIELDS LIKE <skeleton> | FIELDS EXCEPT <skeleton>]
[MEMO]
See Also
ADEL(), ADIR(), AFIELDS(), AFILL(), AINS(), ALEN(), ARRAY(), ASCAN(), ASORT(), COPY TO ARRAY, IN_ARRAY(), IS_ARRAY(), LOCAL, PRIVATE, PUBLIC, SCATTER
Description
The GATHER command replaces fields in the current record with elements from the specified array <array> or, if the MEMVAR keyword is used, from a series of memory variables with the same names as the fields. If the current table is shared, then automatic record locking is performed for the update operation. The data types of the array elements or memory variables and corresponding fields must be compatible. If the array has fewer elements than the number of fields in the record, then fields are modified only up to the number of elements specified. If no matching memory variable is found for a field, the field is unchanged.
FIELDS <field list> | FIELDS LIKE <skeleton> | FIELDS EXCEPT <skeleton>
The optional FIELDS <field list> can be used to restrict the fields updated to those in the comma separated <field list> or those matching the LIKE <skeleton> or those not matching the EXCEPT <skeleton>.
MEMO
By default, memo fields are ignored by the GATHER command. If the MEMO keyword is specified, memo fields will be included.
If SET LOCKTYPE TO OPTIMISTIC is active, an attempt to use the GATHER command on a record that has been modified since it was last read will generate an error.
Example
use demo goto 45 scatter fields last_name, first_name to table_1 append blank gather from table_1 fields last_name, first_name