[Libreoffice-commits] core.git: dbaccess/source
Julien Nabet (via logerrit)
logerrit at kemper.freedesktop.org
Sun Sep 26 11:07:59 UTC 2021
dbaccess/source/ui/dlg/directsql.cxx | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
New commits:
commit 1c1b2b2f8d2abd6d179128b2fc4cb40c490566eb
Author: Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sat Sep 25 17:29:34 2021 +0200
Commit: Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Sun Sep 26 13:07:26 2021 +0200
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 at mamane.lu>
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
Tested-by: Jenkins
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())
More information about the Libreoffice-commits
mailing list