Hi,
By following SxQL and cl-dbi's doc I have come to this workflow:
(defun my-query () (select …))
(let* ((query (dbi:prepare *connection*
(yield my-query)))
(query (dbi:execute query)))
(dbi:fetch[-all] query)
When my query ends with a value
(where (:> :row.quantity 0))))
the SxQL object looks similar:
#<SXQL-STATEMENT: … WHERE (row.quantity > 0)
but I need yield to get the query string, and yield replaces the 0 with a ? placeholder and returns it as a second value:
"… WHERE (row.quantity > ?)""
(0)
then on the call to dbi:execute I have to repeat the 0 argument (which is clearly an issue when the code is split into functions).
I can maybe use multiple-value-bind but I find it unnecessarily tedious. Did I miss something, or could there be a function that simplifies all this?
Thanks
Hi,
By following SxQL and cl-dbi's doc I have come to this workflow:
When my query ends with a value
the SxQL object looks similar:
but I need
yieldto get the query string, andyieldreplaces the0with a?placeholder and returns it as a second value:then on the call to
dbi:executeI have to repeat the0argument (which is clearly an issue when the code is split into functions).I can maybe use
multiple-value-bindbut I find it unnecessarily tedious. Did I miss something, or could there be a function that simplifies all this?Thanks