New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL Results preview pane shows only the results of the very first SQL statement #3860
Comments
|
@gregkvas This is the expected behavior. DBI only accepts one statement, and therefore only the first statement in the SQL preview is getting executed. One option would be to make an enhancement request that DBI accept multiple statements at once. |
|
@ronblum Thank you Ron for the explanation! So the SQL integration preview in RStudio 1.2 works like a DBI::dbSendQuery() function and therefore does not behave like a SQL batch script as i mistakenly thought of. With an enhancement for DBI to act more like a SQL batch script RStudio would really become an alternative SQL IDE. |
|
Hi all, I am using RStudio SQL button to preview my query results before plotting or summarising in RStudio and hoping that evaluating and producing results at least 2 active sql sets would be necessary for me. But, I am not sure what the priorities are for the RStudio dev team. |
|
The behavior of the preview button is as expected, since DBI::dbSendQuery() only accepts one statement. To handle multiple statements, I suggest filing a DBI enhancement request at https://github.com/r-dbi/DBI. Perhaps this could be of use: the following code snippet will execute a single multi-line SQL query from an external file. There is also a discussion about this at https://stackoverflow.com/questions/2003663/import-multiline-sql-query-to-single-string. These will only work for a single statement, though. You might be able to create a workaround and adapt the code examples to split a file with multiple statements—say, separated by semicolons—and looping through them. |
|
@ronblum = thanks for your time and effort to comment on this topic. |
|
I think its will be great if we can execute the SQL code line by line on Rstudio IDE |
|
@TonyFly3000 That sounds like a good suggestion. Can you please file a new enhancement in this repository? This will have the added benefit of other users being able to vote and comment on the request. |
System details
Steps to reproduce the problem
Describe the problem in detail
When defining multiple SQL statements within a generated SQL file in RStudio only the results of the
very first SQL statement is shown when using the preview button "Preview" (Ctrl+Shift+Enter). As can be seen in the screenshot, only the first selection of the top 5 cases of the specific table is previewed and no results for the second SQL statement, where all cases of the specific table are selected.
I have also described this behaviour in RStudio Community: https://community.rstudio.com/t/rstudio-1-2-preview-sql-integration-preview-multiple-sql-statements/17839?u=gregkvas
Describe the behavior you expected
I expected that the results of each SQL statement would be shown in different SQL preview
panes and/or the SQL statements could be invoked to be previewed one by one.
Thank you for any help!
Best, Gregor
The text was updated successfully, but these errors were encountered: