Thanks all for the perspectives. Clearly I misinterpreted the intent of the
design of first-result. I'll use one of the provided options. Thomas, an
enhancement to the sqlite3 egg would be great if you get a chance.
Matt
-=-
On Thu, Jun 9, 2022 at 2:34 AM Thomas Chust wrote:
> Hello Matt,
>
>
Hello Matt,
it may be a bit of an oversight that no such procedure exists in the
SQLite3 egg, but you could define something like this:
(define (one-result/default default db sql . parameters)
(call-with-temporary-statements
(lambda (stmt)
(apply bind-parameters! stmt parameters)
IMO this is an excellent application for folding.
On Wed, Jun 8, 2022 at 10:54 AM Matt Welland wrote:
> The problem: retrieve one value from a query, if there is no matching
> row return a default.
>
> Method 1: use for-each-row, overwrite the default with found values
> Method 2: use
The problem: retrieve one value from a query, if there is no matching
row return a default.
Method 1: use for-each-row, overwrite the default with found values
Method 2: use first-result, on exception return the default
Method 3: use fold-row (wasn't an option when I first wrote the code)
My