1.4 Query Catamorphisms
| (query/foldl [#:connection con] proc init sql) → any/c |
| con : connection? = (current-connection) |
| proc : procedure? |
| init : any/c |
| sql : string? |
Executes sql, left-folding proc over the resulting rows, using init as the initial seed. This call is semantically identical to:
... but is far more efficient in both time and space.
Note that the result of the query may be a side-effect, in which case no iteration occurs and the result is simply returned.
| (query/map [#:connection con] proc sql?) |
| → (or/c side-effect? list?) |
| con : connection? = (current-connection) |
| proc : procedure? |
| sql? : string? |
Executes sql, mapping proc over the resulting rows. This call is semantically identical to:
| (let ((result (query #:connection con sql))) |
| (if (result-set? result) |
| (map (λ (xs) (apply proc xs)) |
| (map vector->list (result-set-rows result))) |
| result)) |
... but is far more efficient in time and space.
Executes sql, mapping proc over the rows in the result set that satisfy pred?. This call is semantically identical to:
... but is far more efficient in time and space.
These procedures behave exactly like their query/... counterparts, except they take prepared statements and argument lists, rather than SQL strings.