• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

loading images and sound files

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi folks...can somebody tell me how to insert images and sound files in oracle table (using lobs) and to retrive them....
thanx in advance...
 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sumit,
These are the steps to insert an image into a blob column.
Step 1.
-------
Create a table to store the blobs:
create table blobs
( id varchar2(255),
blob_col blob
);

Step 2.
-------
Create a logical directory in the database to the physical file system:
create or replace directory MY_FILES as 'c:\images';

Step 3.
-------
Create a procedure to load the blobs from the file system using the logical directory.

create or replace procedure insert_img as
f_lob bfile;
b_lob blob;
begin
insert into blobs values ( 'MyGif', empty_blob() )
return blob_col into b_lob;
f_lob := bfilename( 'MY_FILES', 'whateverimage.gif' );
dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
commit;
end;
/
Hope it helps
Beksy
 
sumit malik
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Beksy,
Thanks for ths code.I tried to use this code , the procedure is compiling but when i am executing the procedure it's not executed because it's not finding the directory.
could u tell why is this so.
cheers
sumit malik

Originally posted by Beksy Kurian:
Sumit,
These are the steps to insert an image into a blob column.
Step 1.
-------
Create a table to store the blobs:
create table blobs
( id varchar2(255),
blob_col blob
);

Step 2.
-------
Create a logical directory in the database to the physical file system:
create or replace directory MY_FILES as 'c:\images';

Step 3.
-------
Create a procedure to load the blobs from the file system using the logical directory.

create or replace procedure insert_img as
f_lob bfile;
b_lob blob;
begin
insert into blobs values ( 'MyGif', empty_blob() )
return blob_col into b_lob;
f_lob := bfilename( 'MY_FILES', 'whateverimage.gif' );
dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
dbms_lob.fileclose(f_lob);
commit;
end;
/
Hope it helps
Beksy

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
When I run the above program it is giving below error...

BEGIN load_file; END;

*
ERROR at line 1:
ORA-22288: file or LOB operation FILEOPEN failed
No such file or directory
ORA-06512: at "SYS.DBMS_LOB", line 504
ORA-06512: at "APPS.LOAD_FILE", line 25
ORA-06512: at line 1

I create a directory called MY_FILES also..

Still getting same error....

Cheers....
Chandu. N
 
I didn't say it. I'm just telling you what this tiny ad said.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic