Im trying to insert a BLOB with PL/SQL Package
In using OnApplyrecord when inserting
I try to use a TOracleQuery.
My Problem is, that I try to get a Image from a Blobfield and write it with a LOBLocator. Im trying TBlobfield.getdata ,Blobfield.value and so on, but don't getting the content. When trying with a Blobstream the Query freezes.
Any Help ?
Source of event
procedure TForm1.ILOracleDataSet1ApplyRecord(Sender: TOracleDataSet;
Action: Char; var Applied: Boolean; var NewRowId: string);
var
LOB : TLOBLocator;
blobfield : TBlobField;
Size : Integer;
Buffer : Pointer;
Stream : TmemoryStream;
longstring : string;
begin
Applied := false;
if Action = 'I' then
begin
LOB := TLOBLocator.Create(Sender.Session, otBLOB);
blobfield := sender.fieldbyname('cont') as TBlobField;
blobfield := ILOracleDataSet1.fieldbyname('cont') as TBlobField;
//Stream:=ILOracleDataSet1.CreateBlobStream((ILOracleDataSet1.fieldbyname('cont') as TBlobField),bmread);
Stream := TmemoryStream.Create;
Size := blobfield.blobsize;
setlength(longstring, size);
//GetMem(Buffer, Size);
longstring := blobfield.CurValue;
stream.Write(longstring, size);
Image1.Picture.Bitmap.LoadFromStream(stream);
OracleQuery1.SetVariable('vblob', longint(LOB));
OracleQuery1.SetVariable('vID', sender.fieldbyName('ID').asinteger);
OracleQuery1.Execute;
NewRowId := OracleQuery1.GetVariable('newRowID');
lob.write(buffer, size);
FreeMem(Buffer);
lob.Free;
Applied := true;
end;
end;
QueryStatement is
begin
:newRowID:=iblob
vid,:vblob);
end;
PLSQL
function iblob(i_id in PLS_INTEGER,vcont in out lobtest.cont%type) return rowid
is
vrowid rowid;
begin
insert into LOBTEST(ID,cont) values (i_id,empty_blob()) returning rowid, cont into vrowid,vcont;
return vrowid;
end;
In using OnApplyrecord when inserting
I try to use a TOracleQuery.
My Problem is, that I try to get a Image from a Blobfield and write it with a LOBLocator. Im trying TBlobfield.getdata ,Blobfield.value and so on, but don't getting the content. When trying with a Blobstream the Query freezes.
Any Help ?
Source of event
procedure TForm1.ILOracleDataSet1ApplyRecord(Sender: TOracleDataSet;
Action: Char; var Applied: Boolean; var NewRowId: string);
var
LOB : TLOBLocator;
blobfield : TBlobField;
Size : Integer;
Buffer : Pointer;
Stream : TmemoryStream;
longstring : string;
begin
Applied := false;
if Action = 'I' then
begin
LOB := TLOBLocator.Create(Sender.Session, otBLOB);
blobfield := sender.fieldbyname('cont') as TBlobField;
blobfield := ILOracleDataSet1.fieldbyname('cont') as TBlobField;
//Stream:=ILOracleDataSet1.CreateBlobStream((ILOracleDataSet1.fieldbyname('cont') as TBlobField),bmread);
Stream := TmemoryStream.Create;
Size := blobfield.blobsize;
setlength(longstring, size);
//GetMem(Buffer, Size);
longstring := blobfield.CurValue;
stream.Write(longstring, size);
Image1.Picture.Bitmap.LoadFromStream(stream);
OracleQuery1.SetVariable('vblob', longint(LOB));
OracleQuery1.SetVariable('vID', sender.fieldbyName('ID').asinteger);
OracleQuery1.Execute;
NewRowId := OracleQuery1.GetVariable('newRowID');
lob.write(buffer, size);
FreeMem(Buffer);
lob.Free;
Applied := true;
end;
end;
QueryStatement is
begin
:newRowID:=iblob

end;
PLSQL
function iblob(i_id in PLS_INTEGER,vcont in out lobtest.cont%type) return rowid
is
vrowid rowid;
begin
insert into LOBTEST(ID,cont) values (i_id,empty_blob()) returning rowid, cont into vrowid,vcont;
return vrowid;
end;