c.haslam Posted January 6, 2019 Posted January 6, 2019 This works, for a single record: Delete from tbl where fnam = 'BAdv2r' and ext = '.wpd' and path = '' but for multiple-record delete, this doesn't: ***657------------------------- $sSqlCmds => <String> (122 chars) 'Delete from tbl where (fnam = 'BAdv2r' and ext = '.pdf' and path = '') or (fnam = 'BAdv2r' and ext = '.wpd' and path = '')' I get ! SQLite.au3 Error --> Function: _SQLite_Exec --> Query: BAdv2r|.wpd|10,840|2017-12-05 18:13||10840| --> Error: near "BAdv2r": syntax error Suggestions? Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
TheXman Posted January 6, 2019 Posted January 6, 2019 (edited) Show the actual lines of code, not the debug statement. The statement below looks correct. Delete from tbl where (fnam = 'BAdv2r' and ext = '.pdf' and path = '') or (fnam = 'BAdv2r' and ext = '.wpd' and path = '') Are you creating the string like this: $sSqlCmds = 'Delete from tbl where (fnam = 'BAdv2r' and ext = '.pdf' and path = '') or (fnam = 'BAdv2r' and ext = '.wpd' and path = '')' or like this: $sSqlCmds = "Delete from tbl where (fnam = 'BAdv2r' and ext = '.pdf' and path = '') or (fnam = 'BAdv2r' and ext = '.wpd' and path = '')" The example wrapped in double quotes would work correctly. The example wrapped in single quotes would fail because the single quotes in the string would need to be doubled up like this: $sSqlCmds = 'Delete from tbl where (fnam = ''BAdv2r'' and ext = ''.pdf'' and path = '''') or (fnam = ''BAdv2r'' and ext = ''.wpd'' and path = '''')' of course it could be another issue all together but it's impossible to tell without the relevant code. Edited January 6, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
jchd Posted January 6, 2019 Posted January 6, 2019 Factorize common terms (and beware your single/double quotes, as @TheXman said): $sSqlCmds = "Delete from tbl where fnam = 'BAdv2r' and ext IN ('.pdf', '.wpd') and path = ''" 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)
c.haslam Posted January 6, 2019 Author Posted January 6, 2019 (edited) Thank you both. Knowing that the SQL code is correct, I then looked again for stupid bugs, and found one: I had _SQLite_Exec(-1,$s) If @error Then MsgBox(0,@ScriptLineNumber,_SQLite_ErrMsg()) _guidebug(@ScriptLineNumber,'$sSqlCmds',$sSqlCmds) EndIf Changing $s to $sSqlCmds fixed the problem. _GuiDebebug here is doing the equivalent of Msgbox, but it does not wrap the text as MsgBox does. It is part of my cDebug debugging aid) Edited January 6, 2019 by c.haslam Spoiler CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard
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