Issue with QUERY and no-result queries
"Chris Capel" <[email protected]>
| Newsgroups | gmane.lisp.clsql.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Running an insert statement like so:
(query (format nil "INSERT INTO table (cola, colb) VALUES ('~A', '~A')"
value1
value2))
against a postgresql-socket backend throws the error "missing-result / Didn't
receive result cursor for query." It might do similar things for other
backends.
Reading the documentation, I find that I'm supposed to use EXECUTE-COMMAND to
execute a query that returns no values. However, I think this is a bug. There's
no reason QUERY shouldn't let you run a command that doesn't return anything if
you want to. The /simple/ conceptual image of QUERY is that it takes some SQL,
either in string form or object form or special-reader-syntax form, and it runs
it against the database, and returns any values that the query happens to
produce. By causing it to throw an error when the query returns a value, you
complicate the concept of the function considerably, and I see no advantage in
the behavior to offset that.
Similarly, by limiting QUERY to only one resultset (at least the
postgresql-socket backend does this), you complicate what the developer has to
keep in mind while using the function. It's logical that running a query that
returns multiple values would return multiple values back to lisp.
So, immediately, I think one should use QUERY for both valued and non-valued SQL
statements, and EXECUTE-COMMAND should be deprecated. In the future, I think
support for multiple return values from QUERY should be considered.
Even if you don't agree with the above, the error message should probably
suggest EXECUTE-COMMAND.
Chris Capel
_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel