Posted By: alexmorel Problem for Blob in Stream - 03/09/04 06:41 PM
I have to convert an image before sending him(it) to the base!

I do not manage to cross(spend) her(it) after the convertion.

Code
Procedure Tform1.ButtonClick(Sender: TObject);
Var LOB : TLobLocator;
    JPG : TJPEGImage;
    MS  : TMemoryStream;
Begin
JPG:=TJPEGImage.Create;

JPG.CompressionQuality:=100;
JPG.Grayscale:=False;
JPG.Assign(DBImage1.Picture.Bitmap;


MS :=TMemoryStream.Create;
JPG.SaveToStream(MS);
MS.Position:=0;

With OracleQuery1 Do
Begin
  SQl.Clear;
  SQL.Add('Insert into imageB values(1, empty_blob()) returning image into :image');
  LOB:=TLobLocator.Create(OracleSessionA, otBlob);
  DeclareVariable('image', otBlob);
  //SetComplexVariable('image', LOB);
  SetComplexVariable('image, MS);
  Execute;
  //LOB.LoadFromFile('c:\test.jpg');
  //LOB.Free;
  OracleSessionA.commit;
End;
End;
A.Morel
Posted By: Marco Kalter Re: Problem for Blob in Stream - 03/09/04 08:52 PM
I think this should do the trick:
Code
Procedure Tform1.ButtonClick(Sender: TObject);
Var LOB : TLobLocator;
    JPG : TJPEGImage;
Begin
  JPG:=TJPEGImage.Create;
  JPG.CompressionQuality:=100;
  JPG.Grayscale:=False;
  JPG.Assign(DBImage1.Picture.Bitmap);
  With OracleQuery1 Do
  Begin
    Clear;
    SQL.Add('Insert into imageB values(1, empty_blob()) returning image into :image');
    LOB:=TLobLocator.Create(OracleSessionA, otBlob);
    DeclareVariable('image', otBlob);
    SetComplexVariable('image', LOB);
    Execute;
    JPG.SaveToStream(LOB);
    LOB.Free;
    OracleSessionA.commit;
  End;
End;
The memory stream is removed, and the JPG is now written directly to the database after an empty BLOB is inserted.
Posted By: alexmorel Re: Problem for Blob in Stream - 03/11/04 12:43 PM
When I execute, he(it) makes me following error:

Code
Ora - 00932 : Types of inconsistent data : Blob Expected; Number Obtained
I see not of or come the error, Thank you in advance.
Posted By: Marco Kalter Re: Problem for Blob in Stream - 03/11/04 10:38 PM
Maybe you need to specify the column list for the insert statement? I can't see how the imageB table is defined.
© Allround Automations forums