-
Notifications
You must be signed in to change notification settings - Fork 34
dbSendQuery expects result set, returns error although statement succeeds #26
Comments
dbSendQuery is basically a copy of the RJDBC S4 method for JDBCConnection which returns a JDBCResult object. Which DBI doc are you referring to? It could be that this error is coming from a print or show method that gets called when printing the return value of dbSendQuery. What happens when you assign the dbSendQuery to a variable? |
What I mean is that dbSendQuery isn't supposed to want a result set, if I understand correctly. This is from ?dbSendQuery:
Assigning the return value from dbSendQuery doesn't produce anything, which is as expected since the function errors out. |
Take a look at the "Value" section to
Obligatory
|
Yep, but none of the dbSendQuery calls in my example should generate output. Do you get the same errors as me? |
If I'm not mistaken (not a SQL guru), none of those are queries, so shouldn't be using dbSendQuery:
If you are looking to create a table, you could use |
No, it's not a query as such, but there are SQL statements that do more than query tables and return a set of rows. For example, CREATE SCHEMA to create a schema, or CREATE INDEX to index a table. In general, you'd use dbSendQuery in such cases to send the statement to the database without needing to retrieve a result set. As you can see though, this is throwing up a bunch of errors for me. It's possible I've misconfigured the database on my end (it's a local instance on my laptop). Do you get the same errors? |
Ok, so looked at how RSQLite handles these sort of queries (ignoring schemas which it doesn't support) and it returns SQLiteResult objects. Running your statements on my server results in same error. I'll take a look. PS - Can I ask how you connected to a local instance of SQL Server? I'd like to be able to do that. |
Looks like dbSendQuery as implemented by RJDBC is not meant for non SELECT statements (or more precisely, statements that do not generate a ResultSet). Indeed, RJDBC has implemented a pretty bespoke method for creating tables which makes use of the non-DBI method I don't want to be hacking away at the RJDBC layer any more than is necessary. So for now, the error message that is returned when send |
Hi Imanuel, I just downloaded SQL Server Enterprise Edition from MSDN and installed it locally. I’m not a database guru either so it took a bit longer than your usual Windows software install, but everything seems to be working fine. If you don’t have an MSDN subscription, you can get SQL Server Express which is a free download: http://www.microsoft.com/en-au/server-cloud/products/sql-server-editions/sql-server-express.aspx No probs with leaving the RJDBC layer alone for now. The statements get executed on the backend anyway, so I can just tell R to ignore the errors. From: Imanuel Costigan [mailto:notifications@github.com] Ok, so looked at how RSQLite handles these sort of queries (ignoring schemas which it doesn't support) and it returns SQLiteResult objects. Running your statements on my server results in same error. I'll take a look. PS - Can I ask how you connected to a local instance of SQL Server? I'd like to be able to do that. — |
It looks like
dbSendQuery
is expecting a result set, although per the DBI docs, it isn't supposed to. While the SQL executes on the database correctly, the function returns an error.Here's a minimal example where I create a schema and a table, insert values into it, and then read the table back into R.
All the
dbSendQuery
calls return errors likebut the final
dbReadTable
shows that the table was created anyway:The text was updated successfully, but these errors were encountered: