Da bei mir der folgende Code
Delphi-Quellcode:
SQLDataSet1.CommandText :=
sql;
SQLDataSet1.Active := true;
ClientDataSet1.Active := true;
Blob := ClientDataSet1.FieldByName ('
f03')
AS TBlobField;
ClientDataSet1.Edit;
Blob.LoadFromStream (str_PDF);
ClientDataSet1.FieldByName ('
f04').AsInteger := 100;
ClientDataSet1.Post;
ClientDataSet1.Active := false;
SQLDataSet1.Active := false;
nicht funktionierte, habe ich folgende Lösung gefunden:
Delphi-Quellcode:
sql := '
insert into t01_r03' +#32
+'
set f01=' +ID +'
,' +#32
+'
f03=:f03';
sql_t01r03.Params.ParamByName('
f03').LoadFromStream(str_PDF, ftBlob);
if sql_t01r03.Sql.Count = 0
then
sql_t01r03.SQL.Add (
sql)
else
sql_t01r03.Sql[0] :=
sql;
sql_t01r03.ExecSQL;
Zum wieder einlesen des Blob funktioniert folgender Code:
Delphi-Quellcode:
sql := '
select * from t01_r03' +#32
+'
where f01=' +ID;
sql_query.Sql.Clear;
sql_query.SQL.Add (
sql);
sql_query.Open;
Stream := sql_query.CreateBlobStream (sql_query.FieldByName('
f03'),bmRead);
MemoryStream.LoadFromStream (Stream);
MemoryStream.SaveToFile (ID+'
.pdf');
sql_query.Close;