summaryrefslogtreecommitdiff
path: root/dbaccess
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2021-09-25 17:29:34 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2021-09-27 13:01:32 +0200
commit638bdd87fc19377b157c82feb073be22c89d32de (patch)
tree1fb44a472f9be791516967eaf394bc489d6e173b /dbaccess
parentc43f185a81e667c5e34a91f5dd1fd1a4e5a33b58 (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: Julien Nabet <serval2412@yahoo.fr> (cherry picked from commit 1c1b2b2f8d2abd6d179128b2fc4cb40c490566eb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122632 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'dbaccess')
-rw-r--r--dbaccess/source/ui/dlg/directsql.cxx23
1 files changed, 22 insertions, 1 deletions
diff --git a/dbaccess/source/ui/dlg/directsql.cxx b/dbaccess/source/ui/dlg/directsql.cxx
index ac3425999cf9..03d7b2115dc8 100644
--- a/dbaccess/source/ui/dlg/directsql.cxx
+++ b/dbaccess/source/ui/dlg/directsql.cxx
@@ -211,7 +211,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())