Jump to content

Recommended Posts

Posted

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

 

Posted (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 by TheXman
Posted

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 here
RegExp tutorial: enough to get started
PCRE 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)

Posted (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 by c.haslam
Spoiler

CDebug Dumps values of variables including arrays and DLL structs, to a GUI, to the Console, and to the Clipboard

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...