Closed gitkatdev closed 1 year ago
I'm not familiar with the CALL
format, but I can do DBI::dbGetQuery(con, "exec my_stored_proc arg1 arg2")
without a problem. Is that different?
Hi, I am facing the very same issue with CALL PROCEDURE format in MySQL DB when I updated odbc package from version 1.2.3 to 1.3.0 or higher. I have the very same connection_string as gitkatdev and I received the following error:
Code: dbGetQuery(cnn, "CALL prc_xxx(15195)") Error in result_fetch(res@ptr, n) : nanodbc/nanodbc.cpp:2695: 24000: [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.18]Fetch without a SELECT
However, I also run the following without a warning: Code: res <- dbSendQuery(cnn, "CALL prc_xxx(15195)")
Dear all,
Quick update on my comments above. It seems that dbFetch works also for Stored Procedure in case I call dbListTables before fetching.
WORKING CODE:
res <- dbSendQuery(cnn, "CALL prc_xxx(?)", params = 15195) dbListTables(cnn) dbFetch(res)
I also noticed that
Without dbListTables()
@Penna88 can you test your use case with: https://github.com/r-dbi/odbc/pull/546
Thanks for your report.
Good morning Detule,
glad to confirm that your fix solved the problem.
Thanks for taking the time to verify / appreciate it.
Issue Description and Expected Result
I've just install R version 4.0.3 (until last week I was using R 3.6) with DBI 1.1.1 and I'm facing a new error that I've never seen before. I have a MySQL database (version 8.0.18) and I use DBI to retrieve data. Specifically, the database includes some stored procedures that prepare a sql statement based on input parameters and execute it. Until last week I was able to retrieve the output of these stored procedures using dbGetQuery (as indicated in the DBI documentation) while after the upgrade to R 4.0.3 I get the following error:
Error in result_fetch(res@ptr, n) : nanodbc/nanodbc.cpp:2695: 24000: [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.23]Fetch without a SELECT
Database
[MySQL][ODBC 8.0(w) Driver][mysqld-8.0.23]
Reproducible Example
Assume there is a simple table called "test_1" like this: intId | strName 1 | Rome 2 | New York 3 | Prague and a stored procedure # called "my_stored_proc" with two input parameters (table_name and id) and the following structure:
BEGIN: SET @t1 =CONCAT('SELECT strName FROM ', table_name, ' WHERE intId =', id, ';' ); PREPARE stmt3 FROM @t1; EXECUTE stmt3; DEALLOCATE PREPARE stmt3; END
In R I then run the following code:
In the paste the above code returns out == "Rome" while I now get the error mentioned above.
Is this an error on my side or a bug?
Thank you in advance Isacco