Oracle Multimedia Basics: Directories
A goal when dealing with multimedia is to load images into the multimedia types, and those images exist on a filesystem.
To load them in, an Oracle directory needs to be defined. This directory allows you to assign a name to a physical location. Access can then be given to users using the granted command. Directories are used by a number of tools including datapump.
Following are examples of creating a directory:
create or replace directory win_mydir as 'c:\temp';
create or replace directory unix_mydir as '/u01/imageloc';
You can then grant read access to a user like:
grant read on directory win_mydir to websys;
Note 1: The directory does not have to exist. Existance is only checked at runtime usage.
Note 2: Access is recursive. You can access subdirectories that exist in this top level directory.
e.g.
If there is a file called c:\temp\subdir\abc.jpg, then you can access it using directory win_mydir and file name called subdir\abc.jpg
The following highlights this concept:
To load them in, an Oracle directory needs to be defined. This directory allows you to assign a name to a physical location. Access can then be given to users using the granted command. Directories are used by a number of tools including datapump.
Following are examples of creating a directory:
create or replace directory win_mydir as 'c:\temp';
create or replace directory unix_mydir as '/u01/imageloc';
You can then grant read access to a user like:
grant read on directory win_mydir to websys;
Note 1: The directory does not have to exist. Existance is only checked at runtime usage.
Note 2: Access is recursive. You can access subdirectories that exist in this top level directory.
e.g.
If there is a file called c:\temp\subdir\abc.jpg, then you can access it using directory win_mydir and file name called subdir\abc.jpg
The following highlights this concept:
create table myaudio(pk integer, myaud ordsys.ordaudio);
insert into myudio values(1,ordsys.ordaudio.init());
commit;
declare
cursor c1 is select * from myaudio for update;
c1rec c1%rowtype;
ctx raw(4000);
begin
open c1;
fetch c1 into c1rec;
close c1;
c1rec.myaud.importfrom(ctx,'FILE','MYDIR','subdir\bwf_short.mp3');
c1rec.myaud.setproperties(ctx);
update myaudio set myaud = c1rec.myaud;
commit;
end;
/
SQL> select m.myaud.audioduration from myaudio m;
MYAUD.AUDIODURATION
-------------------
12
RSS
Email