Forums


Aducom Software :: Forums :: Delphi SQLite Version 3.0.x Components :: Bugs/Enhancement requests
 
<< Voorgaande discussie | Volgende discussie >>
Bug in ASQLiteUpdate Component
Moderators: aducom, aducomadmin2
Auteur Bericht
Fred
zo feb 07 2010, 04:47
Geregistreerde deelnemer #288
Geregistreerd: di dec 20 2005, 11:03
Woonplaats: Republic of Texas, USA
berichten: 5
Albert,

Long time, no communicate!

Just when I thought you had become perfect my update statements startd failing after I upgraded to Win 7 and reinstalled Delphi 7 with your latest(?) package release: ASqlite3NullFTS200902A.zip.

I tried every way possible to blame it on the "Evil Empire" (Mickeysoft) and their latest "virus" release (Win 7.), But alas I was unsuccessful. I finally admitted when all else fails, Debug.

Seems strange to me I am the only one to report this one. I unzipped (the file that is) and reinstalled twice just to make sure.

Using the SQL update statement: "update "tableName" * Where RID = :RID" for the "ASQLite3Update" component property "UpdateSQL.", the update was failing with the error message: 'Syntax error: "where" expected'.

Stepping through the code I found the following (Highlighted in red.)

[pre]
if TheWord = '*' then
begin
for i := 0 to FieldList.Count - 1 do
SQLStr := SQLStr +FieldList[i].FieldName+'='+':'+ FieldList[i].FieldName+',';
System.Delete(SQLStr, Length(SQLStr), 1);

SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
end else begin
if not SyntaxCheck(TheWord, 'set') then
raise AsgError.Create('Syntax error: "set" expected');

repeat
FieldId := GetWord(MySQL, startpos, vartype); // fieldname
SQLStr := SQLStr + FieldId;

TheWord := GetWord(MySQL, startpos, vartype); // '='
if not SyntaxCheck(TheWord, '=') then
raise AsgError.Create('Syntax error: "=" expected')
else SQLStr := SQLStr + '=';

TheWord := GetWord(MySQL, startpos, vartype); // 2004-14-09 (rps) ':' or 'where' --->
if vartype = vtcDelimiter then // <---
TheWord := GetWord(MySQL, startpos, vartype); // fieldvalue
if TheWord = '*' then
SQLStr := SQLStr +':' + FieldId
else
SQLStr := SQLStr +':' + TheWord;


TheWord := GetWord(MySQL, startpos, vartype); // , or 'where'
until AnsiCompareText(TheWord, 'where') = 0;
end;

if not SyntaxCheck(TheWord, 'where') then
raise AsgError.Create('Syntax error: "where" expected')
else
SQLStr := SQLStr + ' where ';


SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
Connection.SQLite3_ExecSQL(SQLStr, Fields);
inherited InternalPost; // rework internals
end

[/pre]

I subsequently modified the highlighted code to the following: (Highlighted in blue.)

<pre>
if TheWord = '*' then
begin
for i := 0 to FieldList.Count - 1 do
SQLStr := SQLStr +FieldList[i].FieldName+'='+':'+ FieldList[i].FieldName+',';
System.Delete(SQLStr, Length(SQLStr), 1);

SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
end else begin
if not SyntaxCheck(TheWord, 'set') then
raise AsgError.Create('Syntax error: "set" expected');

repeat
FieldId := GetWord(MySQL, startpos, vartype); // fieldname
SQLStr := SQLStr + FieldId;

TheWord := GetWord(MySQL, startpos, vartype); // '='
if not SyntaxCheck(TheWord, '=') then
raise AsgError.Create('Syntax error: "=" expected')
else SQLStr := SQLStr + '=';

TheWord := GetWord(MySQL, startpos, vartype); // 2004-14-09 (rps) ':' or 'where' --->
if vartype = vtcDelimiter then // <---
TheWord := GetWord(MySQL, startpos, vartype); // fieldvalue
if TheWord = '*' then
SQLStr := SQLStr +':' + FieldId
else
SQLStr := SQLStr +':' + TheWord;


TheWord := GetWord(MySQL, startpos, vartype); // , or 'where'
until AnsiCompareText(TheWord, 'where') = 0;
if not SyntaxCheck(TheWord, 'where') then
raise AsgError.Create('Syntax error: "where" expected')
else
SQLStr := SQLStr + ' where ';
SQLStr := SQLStr + Copy(MySQL, startpos, 9999);
end;

Connection.SQLite3_ExecSQL(SQLStr, Fields);
inherited InternalPost; // rework internals
end
</pre>


After about thirty seconds if intensive testing, it would appear my problem is solved. Thought I would pass this along for your consideration.

Sorry I could not get the "preformated" tags to work in this message. If you can't decipher what I've done, drop me an email, and I'll send an attachment in reply.

Fred
Terug omhoog
aducom
ma feb 08 2010, 06:27

Geregistreerde deelnemer #1
Geregistreerd: wo jan 25 2006, 04:34
Woonplaats: groningen (NL)
berichten: 1561
TheWord := GetWord(MySQL, startpos, vartype); // , or 'where'
until AnsiCompareText(TheWord, 'where') = 0;
end;

That doesn't seem right does it? I'll look into it

albert
Terug omhoog
 

Ga naar:     Terug omhoog

Publiceer deze discussie: RSS 0.92 Publiceer deze discussie: RSS 2.0 Publiceer deze discussie: RDF
Powered by e107 Forum System