Deye Posted September 2, 2017 Share Posted September 2, 2017 Hi, In this function using WHERE [" & $sColumFind & "] = " & _SQLite_Escape($sValueFind) a. I want to come up with something where I can have $sColumFind ="Colum5_Colum4_Column3_Colum2_Colum1_Colum0" and in $sValueFind have "match_for_5,match_for_4 ....") and accordingly get the right row to do a replacement on Colum6 .. 1. What would be the basic syntax of the command To be more accurate and precised to what i'll need, how can I just send in a $sValueFind array to check if all values exist in a specific row Or if I have to use the syntax mentioned in (a.) I'd just pass the string and get a match for match_for_5 on Colum5 And function will auto walk through Columns using $sValueFind = match_for_# . backto . Match_for_0 excuse me for having little knowledge for command combinations and expansions that can be used with aqlite for now, would just like to see how this can fall in to place Thanks Func _SQLite_update($hDB, $sTable, $sColumFind, $sValueFind, $sColumChange, $sValueChange) $SQLFINDSTRING = "UPDATE [" & $sTable & "] SET [" & $sColumChange & "] = " & _SQLite_Escape($sValueChange) & " WHERE [" & $sColumFind & "] = " & _SQLite_Escape($sValueFind) & ";" ConsoleWrite($SQLFINDSTRING) _SQLite_Exec($hDB, $SQLFINDSTRING) EndFunc ;==>_SQLite_update Link to comment Share on other sites More sharing options...
jchd Posted September 2, 2017 Share Posted September 2, 2017 SQL doesn't offer such function or feature. You'll have to build the WHERE clause string explicitely, like this: update mytable set this_column = that_value, other_column = other_value where explicit_column_X = explicit_value_X AND explicit_column_Y = explicit_value_Y AND explicit_column_Z = explicit_value_Z; Realize that column (just as all other DDL names, like table names) can't be parametrized in SQL. SQLite is no exception in the SQL world. OTOH having such generic need may denote an inapropriate database design, depending on your specific context. 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...
Deye Posted September 2, 2017 Author Share Posted September 2, 2017 (edited) Thanks $sqlString = "SELECT * FROM aManager WHERE '" & $match_for_5 & "' LIKE Colum5 || '%'; " what im currently using is 1. _SQLite_GetTable2d(-1, $sqlString,...) 2. searching $aResults array if a value needs to be updated .. Q. is it possible to pipe SELECT with UPDATE BTW, is this syntax right for adding more criterion s for matching? (Edit: works just tested ..) $sqlString = "SELECT * FROM aManager WHERE '" & $match_for_5 & "' LIKE Colum5 And '" & $match_for_4 & "' LIKE Colum4 || '%'; " I have all the values that need to match from Colum5 to Colum0 Through out all Colum5 = its value is supposed to be unique, but just in case its not, I want to also test\match Colum4_value to Colum0_value for a given row Edited September 2, 2017 by Deye Link to comment Share on other sites More sharing options...
jchd Posted September 2, 2017 Share Posted September 2, 2017 You say you use gettable2d then search the resulting array. But then why don't you refine your select query in the SQL statement rather than with pedestrian code in the array then again in the update statement? Select and update are separate statements. If the update operates on parts or all of the result of the select, then you should group both statements inside a transaction to keep away from updating possibly inconsistent data (another process could change the database in between select & update. OTOH it's very useful and much more efficient to place the select where clause in the update statement itself. If col_5 is meant to be unique (or any combination of columns) then make this/these columns unique (see unique constraint) or primary key. Note that it's pretty hard to advise about DB design without any clue about the semantics of the entities you're managing and the needs of the application(s). 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