Ervan Posted February 11, 2022 Posted February 11, 2022 Hi! In last versions of sqlite it is possible to execute an UPDATE query with return values. I found that the _SqliteGetTable2d function executes the given query incorrectly while the _SQLite_GetTable2d function does correctly. For example: UPDATE table SET Value = 'value' WHERE id IN (SELECT id FROM table WHERE Value > 0 LIMIT 5) RETURNING id'. After _SQLite_GetTable2d DB has 10 changes instead 5. First 5 changes appear after this code execution (in the Sqlite.au3, _SQLite_GetTable2d func): While True $iRval_Step = DllCall($__g_hDll_SQLite, "int:cdecl", "sqlite3_step", "ptr", $hQuery) If @error Then $iError = @error _SQLite_QueryFinalize($hQuery) Return SetError(3, $iError, $SQLITE_MISUSE) ; DllCall error EndIf Switch $iRval_Step[0] Case $SQLITE_ROW $iRows += 1 Case $SQLITE_DONE ExitLoop Case Else _SQLite_QueryFinalize($hQuery) Return SetError(3, $iError, $iRval_Step[0]) EndSwitch WEnd And the last 5 changes appear after Finalize in the end of the func: Return (_SQLite_QueryFinalize($hQuery)) So in the end we have 10 changes but only 5 returns (last changes)
Ervan Posted February 11, 2022 Author Posted February 11, 2022 Edit: I found that the _SqliteGetTable2d function executes the given query incorrectly while the _SQLite_GetTable function does correctly.
Developers Jos Posted February 11, 2022 Developers Posted February 11, 2022 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
jchd Posted February 11, 2022 Posted February 11, 2022 Our SQLite UDF predates the introduction of the RETURNING clause by several years, so it isn"t surprising nothing was setup at that time to support the newest versions of SQLite. I wouldn't call this a bug. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
jchd Posted February 11, 2022 Posted February 11, 2022 The cause of the issue is that the current function performs the query twice: once for counting the output rows, once for populating the resulting array. It's of course possible to rewrite _SQLiteGetTable2D() to change the way it works but I currently don't have much time to devote to this task. Given that the UDF has a number of really important issues (e.g. everything is returned as text instead of datatypes) I don't expect to fix this problem anytime soon, at least not in the next few months. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now