diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2021-09-25 17:29:34 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2021-09-26 13:07:26 +0200 |
commit | 1c1b2b2f8d2abd6d179128b2fc4cb40c490566eb (patch) | |
tree | 043503a7f99cecadac62cf68eea9b647a873aea8 /dbaccess | |
parent | cbf545e0f89a64891a8f35da44f020f7400b58b4 (diff) |
tdf#144694: improve Direct SQL dialog command type heuristics
When the SDBC driver doesn't support multiple results sets:
* special-case INSERT, UPDATE, DELETE like
SELECT already was.
* for unrecognised SQL commands, take the "show output"
checkbox as a hint whether to use executeUpdate()
or executeQuery()
+ create a new var to store statement in uppercase
instead of calling toAsciiUpperCase() repeatedly
Change-Id: I9a7d1d3d93e72e0a42871c1859346c9e40de868e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122608
Reviewed-by: Lionel Mamane <lionel@mamane.lu>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Tested-by: Jenkins
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/dlg/directsql.cxx | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx index e6828ae2aa3c..7a59a1d2c76d 100644 --- a/dbaccess/source/ui/dlg/directsql.cxx +++ b/dbaccess/source/ui/dlg/directsql.cxx @@ -227,7 +227,28 @@ namespace dbaui } else { - if (_rStatement.toAsciiUpperCase().startsWith("SELECT")) + const OUString upperStatement = _rStatement.toAsciiUpperCase(); + if (upperStatement.startsWith("UPDATE")) + { + sal_Int32 resultCount = xStatement->executeUpdate(_rStatement); + addOutputText(OUString(OUString::number(resultCount) + " rows updated\n")); + } + else if (upperStatement.startsWith("INSERT")) + { + sal_Int32 resultCount = xStatement->executeUpdate(_rStatement); + addOutputText(OUString(OUString::number(resultCount) + " rows inserted\n")); + } + else if (upperStatement.startsWith("DELETE")) + { + sal_Int32 resultCount = xStatement->executeUpdate(_rStatement); + addOutputText(OUString(OUString::number(resultCount) + " rows deleted\n")); + } + else if (upperStatement.startsWith("CREATE")) + { + xStatement->executeUpdate(_rStatement); + addOutputText(u"Command executed\n"); + } + else if (upperStatement.startsWith("SELECT") || m_xShowOutput->get_active()) { css::uno::Reference< css::sdbc::XResultSet > xRS = xStatement->executeQuery(_rStatement); if (m_xShowOutput->get_active()) |