TZSQLiteStatement.ExecuteUpdate

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

Locked
DKameleon
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 24.12.2008, 22:52
Contact:

TZSQLiteStatement.ExecuteUpdate

Post by DKameleon »

Was trying to use SQLite on D2009, but during insert got a message:

Code: Select all

SQL Error: near "I": syntax error.
After a little discovery located that function passes to the dll pointer to unicode sting and sqlite fails to parse it:

Code: Select all

function TZSQLiteStatement.ExecuteUpdate(const SQL: string): Integer;
var
  ErrorCode: Integer;
  ErrorMessage: PAnsiChar;
begin
  ErrorMessage := '';
  ErrorCode := FPlainDriver.Execute(FHandle, [b]PAnsiChar(SQL)[/b], nil, nil,
    ErrorMessage);
hope my report will be useful :)

Regards.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

The report would be even more usefull if you can change the code so it just works :) You're into it and thus at the best position to fix it.

Is it enough to include some conversion function in case of D2009? Please send us the code you changed, so we can work it into our code (eventually IFDEF'ed for D2009 only).

Mark
Image
DKameleon
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 24.12.2008, 22:52
Contact:

Post by DKameleon »

Yes, Y've made following change:

Code: Select all

function TZSQLiteStatement.ExecuteUpdate(const SQL: string): Integer;
var
  ErrorCode: Integer;
  ErrorMessage: PAnsiChar;
begin
  ErrorMessage := '';
  ErrorCode := FPlainDriver.Execute(FHandle, PAnsiChar(UTF8String(SQL)), nil, nil,
    ErrorMessage);
Added casting to UTF8String and it becomes working :)
Test also passed with Cyrillic sybmols :)

But select with the same cyrilic gave me wrong result:
I saw previously inserted UTF8 text as ANSI (обменник).

Seems there could be also problem with backward conversion. :(

As I see code above:

Code: Select all

function TZSQLiteStatement.ExecuteQuery(const SQL: string): IZResultSet;
var
  ErrorCode: Integer;
  ErrorMessage: PAnsiChar;
  SQLTail: PAnsiChar;
  StmtHandle: Psqlite_vm;
  ColumnCount: Integer;
  ColumnValues: PPAnsiChar;
  ColumnNames: PPAnsiChar;
begin
  ErrorMessage := '';
  SQLTail := '';
  ColumnCount := 0;
  {$IFDEF DELPHI12_UP}
  ErrorCode := FPlainDriver.Compile(FHandle, PAnsiChar(UTF8String(SQL)), Length(SQL), SQLTail,
    StmtHandle, ErrorMessage);
  {$ELSE}
  ErrorCode := FPlainDriver.Compile(FHandle, PAnsiChar(SQL), Length(SQL), SQLTail,
    StmtHandle, ErrorMessage);
  {$ENDIF}
There was already added casting to UTF8, but not sure about correct results interpretation.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Check what changes are needed in the TZSQLiteResultSet.GetXXXX and TZSQLiteResultSet.GetXXXX functions that retrieve string data.

Mark
Image
tkamphuis
Junior Boarder
Junior Boarder
Posts: 30
Joined: 18.01.2009, 09:20
Contact:

Post by tkamphuis »

I have the same problem when inserting a record in a simple SQLite database (1 field of the varchar type). Is there a workaround?
Locked