Firebird, unicode insert into

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
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Firebird, unicode insert into

Post by SlavoF »

firebird-2.1 , RAD 2009
svn://zeos.firmos.at/zeos/trunk from 11.2.2009

Edit1.Text := 'ľščťžý';

ZTable1.FieldByName('Text1').AsString := Edit1.Text;
stored value is OK

ZSQLProcessor1.Params.CreateParam(FtString, 'T1', ptUnknown);
ZSQLProcessor1.ParamByName('T1').Value := Edit1.Text;
ZSQLProcessor1.Script.Text := 'INSERT INTO ZTable1 Values(:T1)';
ZSQLProcessor1.Execute;
stored value is OK

....
ZSQLProcessor1.Script.Text := 'INSERT INTO ZTable1 Values('+QuotedStr(Edit1.Text)+')';
....
stored value is NOT OK
:(
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Have you tried this?
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

ee, no
:(
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

pardon, sorry
yes tried
is NOT solve this
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

I have Unit ZdbcInterbase6Utils.pas in:
svn://zeos.firmos.at/zeos/trunk from 11.2.2009
with ..... UTF8String(SQL) ....
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

IBC component:
IBCSQL1.SQL.Text := 'insert into Table1 values('+QuotedStr(Edit1.Text)+')';
IBCSQL1.Execute;
in THE SAME DB, SAME PROJECT IS OK
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Open ZVariant.pas

go to

function TZSoftVariantManager.Convert(const Value: TZVariant;
NewType: TZVariantType): TZVariant;
begin
Result.VType := NewType;
case NewType of
vtBoolean:
case Value.VType of
vtNull:
Result.VBoolean := False;
vtBoolean:
Result.VBoolean := Value.VBoolean;
vtInteger:
Result.VBoolean := Value.VInteger <> 0;
vtFloat:
Result.VBoolean := Value.VFloat <> 0;
vtString:
Result.VBoolean := StrToBoolEx(Value.VString);
vtUnicodeString:
Result.VBoolean := StrToBoolEx(Value.VUnicodeString);
vtDateTime:
Result.VBoolean := Value.VDateTime <> 0;
vtPointer:
RaiseTypeMismatchError;
vtInterface:
RaiseTypeMismatchError;
end;
vtInteger:
case Value.VType of
vtNull:
Result.VInteger := 0;
vtBoolean:
if Value.VBoolean then
Result.VInteger := 1
else
Result.VInteger := 0;
vtInteger:
Result.VInteger := Value.VInteger;
vtFloat:
Result.VInteger := Trunc(Value.VFloat);
vtString:
Result.VInteger := StrToIntDef(Value.VString, 0);
vtUnicodeString:
Result.VInteger := StrToIntDef(Value.VUnicodeString, 0);
vtDateTime:
Result.VInteger := Trunc(Value.VDateTime);
vtPointer:
Result.VInteger := Integer(Value.VPointer);
vtInterface:
RaiseTypeMismatchError;
end;
vtFloat:
case Value.VType of
vtNull:
Result.VFloat := 0;
vtBoolean:
if Value.VBoolean then
Result.VFloat := 1
else
Result.VFloat := 0;
vtInteger:
Result.VFloat := Value.VInteger;
vtFloat:
Result.VFloat := Value.VFloat;
vtString:
Result.VFloat := SqlStrToFloatDef(Value.VString, 0);
vtUnicodeString:
Result.VFloat := SqlStrToFloatDef(Value.VUnicodeString, 0);
vtDateTime:
Result.VFloat := Value.VDateTime;
vtPointer:
RaiseTypeMismatchError;
vtInterface:
RaiseTypeMismatchError;
end;
vtString:
case Value.VType of
vtNull:
Result.VString := '';
vtBoolean:
if Value.VBoolean then
Result.VString := 'TRUE'
else
Result.VString := 'FALSE';
vtInteger:
Result.VString := IntToStr(Value.VInteger);
// gto: Not a real threat, as it's converting numbers (unicode safe)
vtFloat:
Result.VString := FloatToSqlStr(Value.VFloat);
// gto: Not a real threat, as it's converting numbers (unicode safe)
vtString:
{$IFDEF DELPHI12_UP}
Result.VString := UTF8String(Value.VString);
{$ELSE}
Result.VString := Value.VString;
{$ENDIF}
vtUnicodeString:
{$IFDEF DELPHI12_UP}
Result.VString := UTF8String(Value.VUnicodeString);
{$ELSE}
Result.VString := Value.VUnicodeString;
{$ENDIF}
vtDateTime:
Result.VString := DateTimeToAnsiSQLDate(Value.VDateTime);
// gto: Not a real threat, as it's converting dates (unicode safe)
vtPointer:
RaiseTypeMismatchError;
vtInterface:
RaiseTypeMismatchError;
end;
vtUnicodeString:
case Value.VType of
vtNull:
Result.VUnicodeString := '';
vtBoolean:
if Value.VBoolean then
Result.VUnicodeString := 'True'
else
Result.VUnicodeString := 'False';
vtInteger:
Result.VUnicodeString := IntToStr(Value.VInteger);
vtFloat:
Result.VUnicodeString := FloatToSqlStr(Value.VFloat);
vtString:
Result.VUnicodeString := Value.VString;
vtUnicodeString:
Result.VUnicodeString := Value.VUnicodeString;
vtDateTime:
Result.VUnicodeString := DateTimeToAnsiSQLDate(Value.VDateTime);
vtPointer:
RaiseTypeMismatchError;
vtInterface:
RaiseTypeMismatchError;
end;
vtDateTime:
case Value.VType of
vtNull:
Result.VDateTime := 0;
vtBoolean:
RaiseTypeMismatchError;
vtInteger:
Result.VDateTime := Value.VInteger;
vtFloat:
Result.VDateTime := Value.VFloat;
vtString:
Result.VDateTime := AnsiSQLDateToDateTime(Value.VString);
vtUnicodeString:
Result.VDateTime := AnsiSQLDateToDateTime(Value.VUnicodeString);
vtDateTime:
Result.VDateTime := Value.VDateTime;
vtPointer:
RaiseTypeMismatchError;
vtInterface:
RaiseTypeMismatchError;
end;
vtPointer:
case Value.VType of
vtNull:
Result.VPointer := nil;
vtBoolean:
RaiseTypeMismatchError;
vtInteger:
Result.VPointer := Pointer(Value.VInteger);
vtFloat:
RaiseTypeMismatchError;
vtString:
RaiseTypeMismatchError;
vtUnicodeString:
RaiseTypeMismatchError;
vtDateTime:
RaiseTypeMismatchError;
vtPointer:
Result.VPointer := Value.VPointer;
vtInterface:
RaiseTypeMismatchError;
end;
vtInterface:
case Value.VType of
vtNull:
Result.VInterface := nil;
vtBoolean:
RaiseTypeMismatchError;
vtInteger:
RaiseTypeMismatchError;
vtFloat:
RaiseTypeMismatchError;
vtString:
RaiseTypeMismatchError;
vtUnicodeString:
RaiseTypeMismatchError;
vtDateTime:
RaiseTypeMismatchError;
vtPointer:
RaiseTypeMismatchError;
vtInterface:
Result.VInterface := Value.VInterface;
end;
end;
end;
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

:hurt:
not solved
still bad
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

Can you download lastest snapshot (601) and apply that change?

It works as expected to me
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

downloaded, applied, instaled - 100% ok
not work
TEST.zip from mscherr:
http://zeos.firmos.at/viewtopic.php?t=2266
not work
http://www.davidplus.sk/test/test.jpg
seawolf
Zeos Dev Team *
Zeos Dev Team *
Posts: 385
Joined: 04.06.2008, 19:50
Contact:

Post by seawolf »

I had you same error .. comparing Zeos trunk and my changes I found that:

Unit ZdbcInterbase6Utils.pas

function PrepareStatement(PlainDriver: IZInterbasePlainDriver;
Handle: PISC_DB_HANDLE; TrHandle: PISC_TR_HANDLE; Dialect: Word;
SQL: string; var StmtHandle: TISC_STMT_HANDLE):
TZIbSqlStatementType;
var
StatusVector: TARRAY_ISC_STATUS;
begin
{ Allocate an sql statement }
PlainDriver.isc_dsql_alloc_statement2(@StatusVector, Handle, @StmtHandle);
CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, Sql);

{ Prepare an sql statement }
{$IFDEF DELPHI12_UP}
PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
0, PAnsiChar(AnsiString(SQL)), Dialect, nil);
{$ELSE}
PlainDriver.isc_dsql_prepare(@StatusVector, TrHandle, @StmtHandle,
0, PAnsiChar(SQL), Dialect, nil);
{$ENDIF}
CheckInterbase6Error(PlainDriver, StatusVector, lcExecute, SQL);
SlavoF
Junior Boarder
Junior Boarder
Posts: 29
Joined: 12.02.2009, 15:31
Location: Nitra, Slovakia
Contact:

Post by SlavoF »

bingo !!!!!!! :lol:

same bug as here:
http://zeos.firmos.at/viewtopic.php?t=2259

this solve also this problem:
http://zeos.firmos.at/viewtopic.php?t=2266
but,
NOT Try this:
... 0, PAnsiChar(UTF8String(SQL)), Dialect, nil); ....
Try this:
... 0, PAnsiChar(AnsiString(SQL)), Dialect, nil); ....

thanks seawolf, good work
Locked