Prefetch

Class: TMMUpdater

function Prefetch(const AWhere: string): Boolean;

Loads rows from the remote MySQL/MariaDB table into the local EDB buffer, using the same SELECT script pipeline as TMMScript. The buffer is cleared before loading. Returns True when the server responded successfully, including when zero rows matched.

Prepare must have been called first. Only available in umUpdate and umUpsert modes.

AWhere is a plain SQL WHERE fragment applied to the SELECT, e.g. 'status = ''pending'' AND region = ''EU'''.
Pass an empty string to load all rows.

BLOB and CLOB columns: Prefetch always downloads BLOB and CLOB values in full — there is no size cap on what goes into the buffer. This is intentional: every column fetched by Prefetch will be written back to the server by Execute. A truncated value in the buffer would be written back as a truncated value, permanently overwriting the original data.

When a BLOB or CLOB cell was stored as a server-side temp file (because it exceeded the out-of-band threshold), Prefetch automatically fetches the full value and places it in the buffer. This repair step requires the table to have a primary key. If any cell cannot be fully retrieved, Prefetch returns False and Execute is blocked until Prefetch is called again successfully.

If the table contains large BLOB or CLOB columns that do not need to be updated, exclude them from UpdateColumns. They will then be absent from the buffer, absent from Prefetch, and absent from Execute.

// Update status and timestamp only; leave 'image' and 'document' untouched
Updater.UpdateColumns := ['id', 'status', 'updated_at'];
Updater.Prepare;
Updater.Prefetch('status = ''pending''');

See Also

(C) 2026 Easygate, Lda