I am using zeoslib 7.1.4-stable, protocol = "FreeTDS_MsSQL-2000" + "msdblibr.dll" and got some trouble with binary fields. If the binary/varbinary value is null, it will not be updated. The varbinary value will be truncated to the size it had before the update.
The table definition is
Code: Select all
create table BinTest (
id_BinTest int identity(1, 1) not null primary key,
Modified datetime not null default (getdate()),
BinTest binary(32),
VarBin varbinary(32)
)
go
insert BinTest (BinTest, VarBin) values (0x0, 0x0)
insert BinTest (BinTest, VarBin) values (NULL, NULL)
insert BinTest (BinTest, VarBin) values (NULL, 0x0)
go
Code: Select all
procedure TfrmMain.Button1Click(Sender: TObject);
var
q: tZQuery;
buf: array[0..31] of byte;
begin
Screen.Cursor:= crHourglass;
FillChar(buf, SizeOf(buf), $FF);
q:= tZQuery.Create(nil);
q.Connection:= ZConnection1;
q.SQL.Text:= 'select * from BinTest';
try
q.Open;
while not q.EOF do begin
q.Edit; // Inserts are working properly !!!
q.FieldByName('Modified').AsDateTime:= Now;
q.FieldByName('BinTest').SetData(@buf);
q.FieldByName('VarBin').SetData(@buf);
// This never raises:
if q.FieldByName('BinTest').IsNull then raise Exception.Create('*F*!!!');
q.Post;
q.Next;
end;
finally
Screen.Cursor:= crDefault;
q.Free;
end;
end;
Code: Select all
UPDATE Foo."dbo".BinTest SET Modified='09.21.2020 09:11:19:454',BinTest=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,VarBin=0xFF WHERE id_BinTest=1
UPDATE Foo."dbo".BinTest SET Modified='09.21.2020 09:11:19:470',BinTest=NULL,VarBin=NULL WHERE id_BinTest=2
UPDATE Foo."dbo".BinTest SET Modified='09.21.2020 09:11:19:476',BinTest=NULL,VarBin=0xFF WHERE id_BinTest=3
kind regards
hoedlmoser