The forum for ZeosLib 7.2 Report problems. Ask for help, post proposals for the new version and Zeoslib 7.2 features here. This is a forum that will be edited once the 7.2.x version goes into RC/stable!!
My personal intention for 7.2 is to speed up the internals as optimal a possible for all IDE's. Hope you can help?! Have fun with testing 7.2
MN7
Fresh Boarder
Posts: 5 Joined: 09.09.2019, 11:11
Post
by MN7 » 09.09.2019, 11:22
BYTES field raises error
'Exception TZAbstractCLob in module Test.exe at 00000000007623A6.'
in this code:
Code: Select all
BlobStream := FZQuery.CreateBlobStream(f, bmRead);
try
BlobSize := BlobStream.Size;
BlobStream.Read(BlobMem^, BlobSize);
finally
BlobStream.Free;
end;
BYTES data field have for example security3.fdb in FB 3.0 installation.
aehimself
Zeos Dev Team
Posts: 810 Joined: 18.11.2018, 17:37
Location: Hungary
Post
by aehimself » 09.09.2019, 21:43
Hello,
You can try reading it to a stream and then converting it to TBytes:
Code: Select all
Var
ms: TMemoryStream;
tb: TBytes;
Begin
ms := TMemoryStream.Create;
Try
(ZQuery.FieldByName('TheField') As TBlobField).SaveToStream(ms);
ms.Position := 0;
SetLength(tb, ms.Size);
ms.Read(tb, ms.Size);
// Do something
Finally
FreeAndNil(ms);
End;
End;
This usually worked for me.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
MN7
Fresh Boarder
Posts: 5 Joined: 09.09.2019, 11:11
Post
by MN7 » 11.09.2019, 11:13
For me works "f.AsBytes".
But "BlobStream := FZQuery.CreateBlobStream(f, bmRead);"
just crashed, not raise EZNotSupported or so (for example).
marsupilami
Platinum Boarder
Posts: 1999 Joined: 17.01.2011, 14:17
Post
by marsupilami » 12.09.2019, 18:07
Which version of Delphi and or / FPC do you use?
MN7
Fresh Boarder
Posts: 5 Joined: 09.09.2019, 11:11
Post
by MN7 » 13.09.2019, 17:41
XE4. But test from scratch get new info.
Code: Select all
procedure Test;
var
ZC: TZConnection;
ZQ: TZQuery;
BlobStream: TStream;
B: TBytes;
begin
ZC := TZConnection.Create(nil);
try
ZQ := TZQuery.Create(ZC);
ZQ.Connection := ZC;
ZC.Protocol := 'interbase';
ZC.User := 'SYSDBA';
ZC.Password := 'masterkey';
ZC.LoginPrompt := False;
ZC.Database := 'Firebird_3_0\security3.fdb'; // with full path
ZC.Connect;
ZQ.SQL.Text := 'select * from "PLG$USERS"';
ZQ.Open;
B := ZQ.FieldByName('PLG$PASSWD').AsBytes;
ShowMessage(Length(B).ToString);
BlobStream := ZQ.CreateBlobStream(ZQ.FieldByName('PLG$PASSWD'), bmRead);
try
ShowMessage(BlobStream.Size.ToString);
finally
BlobStream.Free;
end;
finally
ZC.Free;
end;
end;
'Length(B).ToString' show 64,
'BlobStream.Size.ToString' show 0.