Page 1 of 1

Fix for SQLite's TZUpdateSQL binding bug on v6.6.1 - beta

Posted: 13.05.2007, 07:24
by Howe
Hello,

Here is a quick fix for a bug in the TZSQLiteStatement.Execute() routine. If an empty SQL string is passed into the function it will raise a cryptic error message:

"library routine called out of sequence"

Replace this:

CheckSQLiteError(FPlainDriver, ErrorCode, ErrorMessage, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
try
ErrorCode := FPlainDriver.Step(StmtHandle, ColumnCount,

with this:

CheckSQLiteError(FPlainDriver, ErrorCode, ErrorMessage, lcExecute, SQL);
DriverManager.LogMessage(lcExecute, FPlainDriver.GetProtocol, SQL);
ColumnCount := 0;
if SQL <> '' then
try
ErrorCode := FPlainDriver.Step(StmtHandle, ColumnCount,

... in the referred routine.

Can anyone else please confirm this works ?

Thanks,
Howe

Posted: 13.05.2007, 19:35
by aducom
I'll check it out.

albert

Posted: 29.05.2007, 14:30
by aducom
The real reason why it is not working is because it is a general bug. It can be (temporarely) solved by:

Code: Select all

{**
  Checks the correct SQL query.
}
procedure TZAbstractRODataset.CheckSQLQuery;
begin
  if Trim(FSQL.Text)='' then                              // 20070529 Aducom
    raise EZSQLException.Create(SQueryIsEmpty);   // 20070529 Aducom
  if FSQL.StatementCount < 1 then
    raise EZDatabaseError.Create(SQueryIsEmpty);
  if FSQL.StatementCount > 1 then
    raise EZDatabaseError.Create(SCanNotExecuteMoreQueries);
end;
You'll find it in ZAbstractRODataset

albert

Posted: 30.05.2007, 18:48
by mdaems
I just committed a more correct solution (SVN rev. 256). Now FSQL.statementcount correctly returns 0 when the query string is empty. This had some implications on other components too. So the patch was a little more complicated. It will be in next 'Testing' snapshot. Meanwhile you can solve it as above.

Mark