7.0.5 TZMySQLPreparedResultSet.GetLong problem
Posted: 09.09.2013, 21:21
Hello.
Next code pretty show bug...
Normal IZStatement (MySQL) works well but IZPreparedStatement (MySQL) don't.
I try fix this error and i replace original metod:
with this code
I don't know if this is good solution, but works for me. I suggest that bug occur for TZMySQLPreparedResultSet. In normal TZMySQLResultSet all works well. I don't test another DBs.
Sorry for me poor English.
Next code pretty show bug...
Normal IZStatement (MySQL) works well but IZPreparedStatement (MySQL) don't.
Code: Select all
var
LStat: IZStatement;
LPrepStat: IZPreparedStatement;
LRS: IZResultSet;
sTableQuery: string;
ZVariant: TZVariant;
LInfo: TStringList;
sConString: string;
LZeos: IZConnection;
begin
sConString := Format('zdbc:%s://%s:%d/%s?UID=%s;PWD=%s', ['mysql-5', '127.0.0.1', 4434, 'aslibex_dunit_zeos', 'root', '']);
LZeos := DriverManager.GetConnection(sConString);
sTableQuery := 'CREATE TABLE Error_test ('+
' IntField INT'+
')'+
'COLLATE=''utf8_general_ci''' + #13#10 +
'ENGINE=InnoDB';
LStat := LZeos.CreateStatement;
//Create table
LStat.ExecuteUpdate(sTableQuery);
//Insert two rows with values 5 and -5.
Check(
LStat.ExecuteUpdate('INSERT INTO Error_test (IntField) VALUES (5);') = 1);
Check(
LStat.ExecuteUpdate('INSERT INTO Error_test (IntField) VALUES (-5);') = 1);
LRS := LStat.ExecuteQuery('SELECT * FROM Error_test');
//Get first row with value 5
Check(LRS.Next);
ZVariant := LRS.GetValueByName('IntField');
if ZVariant.VInteger <> 5 then
raise Exception.Create('Error');
//Get second row with value -5
Check(LRS.Next);
ZVariant := LRS.GetValueByName('IntField');
if ZVariant.VInteger <> -5 then
raise Exception.Create('Error');
LRS := nil;
LStat := nil;
/// Now i use PreparedStatement!
////////////////////////////////
LInfo := TStringList.Create;
LInfo.Add('preferprepared=true');
LPrepStat := LZeos.PrepareStatementWithParams('SELECT * FROM Error_test;', LInfo);
LRS := LPrepStat.ExecuteQueryPrepared;
//Get first row with value 5
Check(LRS.Next);
ZVariant := LRS.GetValueByName('IntField');
if ZVariant.VInteger <> 5 then
raise Exception.Create('Error');
//Get second row with value -5
Check(LRS.Next);
ZVariant := LRS.GetValueByName('IntField');
if ZVariant.VInteger <> -5 then
raise Exception.Create('Error'); //<<<< this error occurs !!! !!! !!!
LRS := nil;
LPrepStat := nil;
LInfo.Free;
end;
Code: Select all
function TZMySQLPreparedResultSet.GetLong(ColumnIndex: Integer): Int64;
var
full64, bitmask: Int64;
Begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stLong);
{$ENDIF}
full64 := bufferasInt64(ColumnIndex);
bitmask := $FFFFFFFF;
Result := Int64(full64 and bitmask);
LastWasNull := FColumnArray[ColumnIndex-1].is_null =1;
end;
Code: Select all
function TZMySQLPreparedResultSet.GetLong(ColumnIndex: Integer): Int64;
var
full64, bitmask: Int64;
Begin
{$IFNDEF DISABLE_CHECKING}
CheckColumnConvertion(ColumnIndex, stLong);
{$ENDIF}
Result := bufferasInt64(ColumnIndex); //Dak_alpha
LastWasNull := FColumnArray[ColumnIndex-1].is_null =1;
end;
Sorry for me poor English.