panoss Posted July 30, 2018 Share Posted July 30, 2018 (edited) I 'm using SQLite.au3. What I want to do is navigate through the records of a recordset, go to first, last, previous, next record. I read about indexes, I also learnt that SQLite automatically creates a column named rowid (which might be useful). And found something relative. How would you suggest to do this? Maybe there is already some library or code snippet for this functionality? Edited July 30, 2018 by panoss Link to comment Share on other sites More sharing options...
Earthshine Posted July 30, 2018 Share Posted July 30, 2018 (edited) the help file is a great place to start. seriously. they even have working example code _SQLite_Query Edited July 30, 2018 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 30, 2018 Share Posted July 30, 2018 (edited) Hi @panoss SQLite is a great tool to work with, but everything depends about on what do you want to do. As @Earthshine stated, the best place where to start, is the Help file. From there, you can see how the different _SQLite* functions are used, and so, you can even see if there is already something that could fit your request. The expert about SQLite ( as I noticed in these years ), is @jchd. So, let's see if he could suggest to you more Edited July 30, 2018 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
AutoBert Posted July 30, 2018 Share Posted July 30, 2018 If you want to understand SQLite, read about it: http://www.sqlitetutorial.net/ and try to make a AutoIt script. Most powerfull func in AutoIt for querying is _SQLite_GetTable2d, for inserting, updating and dbcreation and -manipulation (Alter) you must have a look at _SQLite_Exec. Link to comment Share on other sites More sharing options...
BrewManNH Posted July 31, 2018 Share Posted July 31, 2018 SQLite doesn't automatically store the rows in the order you inserted them, you'd need to index the table otherwise the rows could be in any order and you can't go forwards and backwards the way I think you're wanting to do. Better to just read the whole table into an array and navigate through it instead. Earthshine 1 If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
panoss Posted July 31, 2018 Author Share Posted July 31, 2018 5 hours ago, BrewManNH said: Better to just read the whole table into an array and navigate through it instead. This was my first thought but doesn't sound very...'professional'. I think the use of indexes is a better approach. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted July 31, 2018 Share Posted July 31, 2018 @panoss I don't see anything wrong with the suggest of @BrewManNH. It's a functional, smart, and easy solution for what you're trying to do Just query the Database, store the result in an array, and navigate through the array. panoss 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
jchd Posted July 31, 2018 Share Posted July 31, 2018 (edited) 13 hours ago, panoss said: This was my first thought but doesn't sound very...'professional'. This is how SQL works, by design. SQL is based on relational algebra and is (roughly) dealing with mathematical sets and ternary logic. Sets have no intrinsic order so if you're asked to list elements of the set of natural integers between 1 and 5 inclusive, you're free to say "4, 2, 5, 3, 1" or "3, 4, 5, 2, 1" or "1, 2, 3, 5, 4" or whatever order you want. All these answers are correct. Of course you can define a partial or complete order over many sets and if the task specifies "... in increasing order" then the only correct answer is "1, 2, 3, 4, 5" if "increasing" means > (the greater than mathematical operator). Moral: in SQL the query SELECT * FROM MyTable may return rows (if any) in any order. In this context, first, last, previous, next have no sense. Many RDBMS offer windowing functions which allow to navigate ad libidum inside a resultset, but such functions are not (yet) available in SQLite. SQLite is like its name says: lite! Edited July 31, 2018 by jchd Typos panoss 1 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) Link to comment Share on other sites More sharing options...
Skysnake Posted August 3, 2018 Share Posted August 3, 2018 The solution may be here: Skysnake Why is the snake in the sky? Link to comment Share on other sites More sharing options...
jchd Posted August 3, 2018 Share Posted August 3, 2018 (edited) A note for SQLite users who wonder: the dev team of SQLite is in the process of offering windowing functions. They are part of the current draft release: http://www.sqlite.org/draft/releaselog/3_25_0.html But don't forget this is just draft, subject to changes. Edited August 3, 2018 by jchd Earthshine and Skysnake 2 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) Link to comment Share on other sites More sharing options...
vijaydeveloper Posted February 18, 2019 Share Posted February 18, 2019 Using PostgreSQL's, specifically and,LAGLEAD should be able to show you the previous and next entries in your table. select * from ( select id, thread_id, is_notice, title, content, lag(id) over (order by is_notice desc, thread_id desc, id asc) as prev, lead(id) over (order by is_notice desc, thread_id desc, id asc) as next from post ) x where 3 IN (id, prev, next); Too learn more or get SQLite tutorials from here. Link to comment Share on other sites More sharing options...
jchd Posted February 19, 2019 Share Posted February 19, 2019 The definitive source of SQLite docs is https://www.sqlite.org/index.html 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) Link to comment Share on other sites More sharing options...
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