Skip to content

Question on usage when yields "extracts" data out of the query #53

Description

@vindarel

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions