Champak Posted December 10, 2015 Share Posted December 10, 2015 'RecNo' is an automatic column inserted as the first column in the databases. I believe it is an index. Why can't I select it? Everytime I try, I get a message that the column doesnt exist, but when I input another column there is no issue. Is there a way to do work based on the 'RecNo'. Link to comment Share on other sites More sharing options...
JohnOne Posted December 10, 2015 Share Posted December 10, 2015 If there are no columns to work on, I doubt it, the column is most likely created when you add an actual content column, else the db would be instantly of maximum size. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted December 10, 2015 Share Posted December 10, 2015 But I believe you can access it by querying rowid. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kylomas Posted December 11, 2015 Share Posted December 11, 2015 (edited) Champak,You can use "rowid", "oid" or "_rowid_". See the SQLite doc here for a discussion of this. See also the doc for "Vacuum". A quick and dirty example...expandcollapse popup#include <ListViewConstants.au3> #include <GUIConstantsEx.au3> #include <sqlite.au3> #include <array.au3> #AutoIt3Wrapper_Add_Constants=n _SQLite_Startup() _SQLite_Open() Local $sql = 'create table if not exists T1 (Fname, Lname);' $sql &= ' insert into T1 values("Bob", "Bumbleburger"),("Bubba", "Baddass"),("Barbara","Buster"),("Boogie Man","Boozenhammer");' _SQLite_Exec(-1, $sql) Local $aRows, $iRows, $iCols _SQLite_GetTable2d(-1, 'Select rowid,* from T1', $aRows, $iRows, $iCols) Local $gui010 = GUICreate('Listview with Row Id''s') Local $lst010 = GUICtrlCreateListView('Rowid | First Name | Last Name', 10, 10, 380, 380, Default, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)) For $i = 1 To UBound($aRows) - 1 GUICtrlCreateListViewItem($aRows[$i][0] & '|' & $aRows[$i][1] & '|' & $aRows[$i][2], $lst010) Next GUISetState() While 1 Switch GUIGetMsg() Case $Gui_Event_Close _SQLite_Close() _SQLite_Shutdown() Exit EndSwitch WEnd Func ShowSomeDBStuff() _SQLite_GetTable2d(-1, 'Select rowid,* from T1', $aRows, $iRows, $iCols) _ArrayDisplay($aRows, "DB As Loaded") _SQLite_Exec(-1, 'delete from T1 where Fname = "Barbara";') _SQLite_GetTable2d(-1, 'Select rowid,* from T1', $aRows, $iRows, $iCols) _ArrayDisplay($aRows, "Entry 3 (Barabara) Deleted") _SQLite_Exec(-1, 'insert into t1 values("Boomerang","Boom");') _SQLite_GetTable2d(-1, 'Select rowid,* from T1', $aRows, $iRows, $iCols) _ArrayDisplay($aRows, "New Entry Added...Recno = 5") _SQLite_Exec(-1, 'vacuum;') _SQLite_GetTable2d(-1, 'Select rowid,* from T1', $aRows, $iRows, $iCols) _ArrayDisplay($aRows, "Keys renumbered by vacuum") EndFunc ;==>ShowSomeDBStuffkylomas Edited December 11, 2015 by kylomas spelling Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted December 11, 2015 Share Posted December 11, 2015 Without seeing the table DDL (the schema), it's pretty hard to tell you something really useful. Is it an SQLite table you designed? In this case post the table declaration. Is it produced by someone else? Then run the following statement and post its result: select * from sqlite_master;You'll find that using a 3rd-party SQLite manager will save 90% of the time you spend on most DB operations. I warmly recommend using SQLite Expert (the freeware version will do). Skysnake 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...
Champak Posted December 11, 2015 Author Share Posted December 11, 2015 "Rowid' worked like a charm. Initially it wasn't working when selecting the same row number, then I remember you VAGUELY...lol...mentioning "vacuum" and everything was smooth from there, thanks.One more thing, I have a slight issue with the following:_SQLite_Query($DB_GasDriving_Log, "SELECT sum(replace(Cost, '$', '')) FROM Log_Fuel_Travel", $hQuery) While _SQLite_FetchData($hQuery, $aRow) = $SQLITE_OK $TOTALFUELCOST &= $aRow[0] WEndIt works fine, but I was wondering if I can do this without the While loop? Or if I can do any select query that has a specific WHERE condition and get the result directly without doing the While loop. Just trying to reduce code. Link to comment Share on other sites More sharing options...
jchd Posted December 11, 2015 Share Posted December 11, 2015 *_Query + *_FetchData is a pedestrian solution. Try using _SQLite_GetTable[2d] or *_GetSingleRow.Feel free to use a WHERE clause in your SQL, of course. 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...
Champak Posted December 12, 2015 Author Share Posted December 12, 2015 Thanks. 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