Link to home
Start Free TrialLog in
Avatar of Mohammed Nasman
Mohammed NasmanFlag for Palestine, State of

asked on

Storing Images in BLOB Fields with Oracle Database

Hello

 I'm trying to storing image in oracle database, I made a table for test contian two fields

Id : number
PIC : BLOB

 I made form and I use DBImage to link the pic field, but when i try to post it give me some errors
ORA-22990
and some times, it tell me, BLOB Lenght error
and when i stored image in the datbase file(usein oracle developer not delphi), when i run the form, it give me this error
invalide picture format

have any one tried to save images in oracle database?

Mohammed Nasman
ASKER CERTIFIED SOLUTION
Avatar of Epsylon
Epsylon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kretzschmar
as eps said,

but tdbimage can't display only a few image-formats,
because the bde adds a prefix to the image-information to determine which format is stored.

use a timage instead of tdbimage and provide the fieldcontent to the timage in a afterscroll-event of the dataset (streaming-> shown by eps).

for inserting use a query like

insert into table (id, pic) values (:id,:pic)

for the pic-param use the methods loadfromstream or loadfromfile to prepare with blobdata before you are executing this query

meikl ;-)
Avatar of Epsylon
Epsylon

That's right  :o)


If you want to display JPEG images you can use a TJPEGImage and then assign it to a TImage:


var j: TJPEGImage;

with Table1 do
begin
bs := TBlobStream(CreateBlobStream(FieldByName('Image'), bmRead));
j := TJPEGImage.Create;
j.LoadFromStream(bs);
Image1.Picture.Assign(j);
bs.Free;
j.Free;
end;
Avatar of Mohammed Nasman

ASKER

Hello Epsylon

  I'm still have this error when i write to database

  Invalide blob length

remeber that i use oracle database to store the images

can you give a full sample that read the images from database to image1 component, and write picture from image1 component to the database using the Tstream as you gave me, I will give you more poinst if you want

thanks for help