update-tuples ( query/tuple quot: ( tuple -- tuple'/f ) -- )
High-level tuple/database integration ยป High-level tuple/database words

Prev:update-tuple ( tuple -- )
Next:delete-tuples ( tuple -- )


Vocabulary
db.tuples

Inputs
query/tuplea tuple
quota quotation with stack effect ( tuple -- tuple'/f )


Outputs
None

Word description
An SQL query is constructed from the slots of the exemplar tuple that are not f. The quot is applied to each tuple from the database that matches the query, and the changed tuple is stored back to the database. If the quot returns f, the tuple is dropped, and its data remains unmodified in the database.

The word is equivalent to the following code:
query/tuple select-tuples quot map sift [ update-tuple ] each

The difference is that update-tuples handles query results one by one, thus avoiding the overhead of allocating the intermediate array of tuples, which select-tuples would do. This is important when processing large amounts of data in limited memory.

See also
insert-tuple, update-tuple, delete-tuples, reject-tuples

Definition


: update-tuples
( query/tuple quot: ( tuple -- tuple'/f ) -- )
[ [ update-tuple ] when* ] compose each-tuple ; inline