Re: How best to get a default result from sqlite3, or to use or not use first-result?

2022-06-11 Thread Matt Welland
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, > >

Re: How best to get a default result from sqlite3, or to use or not use first-result?

2022-06-09 Thread Thomas Chust
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)

Re: How best to get a default result from sqlite3, or to use or not use first-result?

2022-06-08 Thread John Cowan
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

How best to get a default result from sqlite3, or to use or not use first-result?

2022-06-08 Thread Matt Welland
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