Created attachment 130288 [details] Open the database and try the code as described for get the last inserted AutoValue Open the attached Firebird 3 database. Open Tools > SQL... Mark "Show output of "select" statements. Copy the following code: INSERT INTO "Table" ("Name", "Town") VALUES ('Mike', 'Alexandria') RETURNING "ID", "Name", "Town"; There is no value shown as output. The status shows only "1." Expected is in "output": 4;Mike;Alexandria There is a function in HSQLDB named "CALL IDENTITY()" This gives you the last inserted AutoValue. I hope to find this in Firebird. There it should run with RETURNING, but doesn't run in Tools > SQL... Will test this later with macros to see, if it's a problem of internal Firebird or a problem of the SQL-dialog.
Reproducible. Version: 5.4.0.0.alpha0+ Build ID: 92a1ad1f36b6d3cc13135a8c0805508933011577 CPU Threads: 4; OS Version: Windows 6.19; UI Render: default; TinderBox: Win-x86@42, Branch:master, Time: 2017-01-06_23:42:59
Have tested this with a macro. Firebird returns nothing to Base except a "." So there couldn't be tested the last input and the last inserted AutoValue. All tested with Version: 5.4.0.0.alpha0+ Build ID: a3cf075880db31f77cd0550e0ee25eca931c6a40 CPU Threads: 4; OS Version: Linux 4.1; UI Render: default; VCL: kde4; TinderBox: Linux-rpm_deb-x86_64@70-TDF, Branch:master, Time: 2017-01-05_01:21:50 Locale: de-DE (de_DE.UTF-8); Calc: group
(In reply to robert from comment #2) > Have tested this with a macro. Could you please share the macro? Did you use executeQuery or execute? (I assume not executeUpdate...)
Created attachment 138875 [details] Testdatabase, also with code executed by macro: Input data works, returns nothing It's only the same way as executed in Tools > SQL. Code is executed and returns nothing, so the macro couldn't find an object, only a "."
(In reply to Lionel Elie Mamane from comment #3) > Could you please share the macro? Did you use executeQuery or execute? (I > assume not executeUpdate...) Did use executeQuery, because I need a result. By the way: very much people helping hunting and solving Base-bugs last week. Great!
** Please read this message in its entirety before responding ** To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year. There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present. If you have time, please do the following: Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/ If the bug is present, please leave a comment that includes the information from Help - About LibreOffice. If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice. Please DO NOT Update the version field Reply via email (please reply directly on the bug tracker) Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not appropriate in this case) If you want to do more to help you can test to see if your issue is a REGRESSION. To do so: 1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from http://downloadarchive.documentfoundation.org/libreoffice/old/ 2. Test your bug 3. Leave a comment with your results. 4a. If the bug was present with 3.3 - set version to 'inherited from OOo'; 4b. If the bug was not present in 3.3 - add 'regression' to keyword Feel free to come ask questions or to say hello in our QA chat: https://kiwiirc.com/nextclient/irc.freenode.net/#libreoffice-qa Thank you for helping us make LibreOffice even better for everyone! Warm Regards, QA Team MassPing-UntouchedBug
Bug still exists. Tested with Version: 6.2.0.1 Build ID: 0412ee99e862f384c1106d0841a950c4cfaa9df1 CPU threads: 6; OS: Linux 4.12; UI render: default; VCL: gtk3; Locale: de-DE (de_DE.UTF-8); UI-Language: en-US Calc: threaded Also with LO 6.1.4.2 on OpenSUSE 64bit rpm Linux
Created attachment 153043 [details] New Testdatabase - old database seems to be broken. During a crash in bugzilla the database seems to be broken. With LO 6.2.5.2 the Update-command returns '0 rows updated' - which is totally wrong. There has been added a row. RETURNING should show the content of the added row. With LO 6.3.0.2 the whole LO crashes immediately after sending the command to the database. crashreport.libreoffice.org/stats/crash_details/4327a91e-a61b-4700-a574-3df6bfc3654d crashreport.libreoffice.org/stats/crash_details/d090119c-4dd9-41bd-966e-a34319b6c537 All tested with OpenSUSE 15 64bit rpm Linux
Some small pointers: The direct SQL dialog is here: dbaccess/source/ui/dlg/directsql.cxx About HSQLDB's IDENTITY(), search in this guide: http://hsqldb.org/doc/1.8/guide/guide.html
Hmm, but according to https://wiki.documentfoundation.org/Documentation/FirebirdMigration#Data_engine_standard_functions Firebird does not have a function matching IDENTITY()
Just for the record because I'm not sure it could help here, I found a 2 steps way to do this: 1) Retrieve the generator name SELECT relfields.RDB$generator_name FROM RDB$RELATION_FIELDS relfields JOIN RDB$FIELDS fields on (fields.RDB$FIELD_NAME = relfields.RDB$FIELD_SOURCE) WHERE (1 = 1) AND relfields.RDB$RELATION_NAME = '<table>' 2) Use specific Firebird function SELECT GEN_ID( "<generator name>", 0 ) FROM RDB$DATABASE;
Have tested this again. Nothing changed. @Julien: The way you described is the workaround I have also written in Base Handbuch: SELECT RDB$FIELD_NAME, RDB$RELATION_NAME, RDB$GENERATOR_NAME FROM RDB$RELATION_FIELDS WHERE RDB$GENERATOR_NAME IS NOT NULL; You could see the name for the generator. It is the same way autovalue is implemented. SELECT GEN_ID(RDB$1, 1) FROM RDB$DATABASE; Generator with name RDB$1 is asked for the next generated value. INSERT INTO "Table" ("ID", "Field") VALUES (<generated value>, 'Test'); This is the only save mode to get the right data after you inserted a new row: First the value will be blocked for AutoValue, then this blocked value will be used for insert.
(In reply to Robert Großkopf from comment #12) > Have tested this again. Nothing changed. > ... Ok then. Just for the record, here's the entry point. In dbaccess/source/ui/dlg/directsql.cxx, we got: 260 else if (upperStatement.startsWith("INSERT")) 261 { 262 sal_Int32 resultCount = xStatement->executeUpdate(_rStatement); 263 addOutputText(OUStringConcatenation(OUString::number(resultCount) + " rows inserted\n")); 264 } see https://opengrok.libreoffice.org/xref/core/dbaccess/source/ui/dlg/directsql.cxx?r=be73c64d#260 We only expect the number of rows inserted here. I thought we could add a test here to check if it contains RETURNING but no idea then how to retrieve the returned values.
(In reply to Julien Nabet from comment #13) > > We only expect the number of rows inserted here. > I thought we could add a test here to check if it contains RETURNING but no > idea then how to retrieve the returned values. This is the same behavior in Basic macros: You could execute the INSERT with the executeQuery method and will get "*Cursor is not open" when trying to receive the result: *Cursor is not open caused by 'isc_dsql_fetch' /home/buildslave/source/libo-core/connectivity/source/drivers/firebird/Util.cxx:68. You could start the INSERT with executeUpdate and get a number, which is count wrong for Firebird: 0. But you won't get any other result. Seems returning content when inserting values is a special beahvior of Firebird, which can't work with this construction of executeQuery and executeUpdate.
(In reply to Robert Großkopf from comment #14) > > Seems returning content when inserting values is a special behavior of > Firebird, which can't work with this construction of executeQuery and > executeUpdate. Forget the last part. RETURNING is also used in PostgreSQL. It will work there also together width LO. Had tested this a time ago with BASIC: stSql = "INSERT INTO ""Table"" (""Name"") Values('Robert') RETURNING ""ID""" oResult = oSQL_Statement.executeQuery(stSql) oResult.Next loID = oResult.getLong(1) It will work there.
(In reply to Robert Großkopf from comment #15) > (In reply to Robert Großkopf from comment #14) > > > > Seems returning content when inserting values is a special behavior of > > Firebird, which can't work with this construction of executeQuery and > > executeUpdate. > > Forget the last part. RETURNING is also used in PostgreSQL. It will work > there also together width LO. Had tested this a time ago with BASIC: > > stSql = "INSERT INTO ""Table"" (""Name"") Values('Robert') RETURNING ""ID""" > oResult = oSQL_Statement.executeQuery(stSql) > oResult.Next > loID = oResult.getLong(1) > > It will work there. ok so at least we know now that it only depends on the implementation (so connectivity part) and directsql part (in dbaccess) is already ok to take into account. Now I don't know at all how to implement this.