Oracle MultiMedia Audio
Version 11.2.0.3

General Information
Noterow
AUTHID CURRENT_USER
Dependencies
DBMS_LOB ORDAUDIO_PKG ORDSOURCE
ONLINE_MEDIA ORDDOC ORDUTIL
ORDAUDIO ORDERROR ORDX_DEFAULT_AUDIO
ORDAUDIOEXCEPTIONS ORDIMERRORCODES  
Required Schemas
MDSYS ORDPLUGINS ORDSYS
Required System Privileges GRANT create any directory TO <schema_name>;
GRANT create any directory TO uwlass;
Sample Audeo Files Click here to download 9_1_1.mp3
Click here to download thing.wav
For the demo on this page copy 9_1_1.mp3 to c:\temp or if on a real operating system to $HOME and make the appropriate change to the CREATE DIRECTORY DDL below.
Security Model Execute is granted to PUBLIC
Source {$ORACLE_HOME}/ord/im/admin
 
MultiMedia Audio Demo
Actions as SYS conn / as sysdba

ALTER USER ordsys ACCOUNT UNLOCK IDENTIFIED BY ordsys;
GRANT create session TO ordsys;

-- if an application schema does not already exist
CREATE USER uwclass
IDENTIFIED BY uwclass
DEFAULT TABLESPACE uwdata
TEMPORARY TABLESPACE temp
QUOTA 0 ON SYSTEM
QUOTA UNLIMITED ON uwdata;

GRANT create session TO uwclass;
GRANT create any directory TO uwclass;
GRANT create table TO uwclass;
GRANT create directory TO uwclass;

CREATE OR REPLACE DIRECTORY audiodir AS 'c:\temp';

grant all on directory audiodir to uwclass;
Actions as application owner conn uwclass/uwclass

-- verify required objects are visible to schema
SELECT owner, object_name, status
FROM all_objects
WHERE object_name LIKE 'ORD%AUD%';

conn ordsys/ordsys

col owner format a10
col library_name format a15
col file_spec format a55

SELECT *
FROM all_libraries;

-- explore what ordaudio is
SELECT object_type
FROM user_objects
WHERE object_name = 'ORDAUDIO';

SELECT DISTINCT object_name
FROM user_arguments
WHERE package_name = 'ORDAUDIO'
ORDER BY 1;

conn uwclass/uwclass

CREATE TABLE t_audio (
aid   NUMBER,
audio ordsys.ordAudio);

desc t_audio

set describe depth all

desc t_audio

set describe depth all linenum on indent on

desc t_audio

-- create initial records
INSERT INTO t_audio VALUES (1, ordsys.ordAudio.init());
INSERT INTO t_audio VALUES (2, ordsys.ordAudio.init());
COMMIT;

-- this will fail
SELECT * FROM t_audio;
-- this will suceed
SELECT aid FROM t_audio;

set serveroutput on

-- check audio attributes by calling methods
DECLARE
 obj ordsys.ordAudio;
BEGIN
  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 1;

-- access methods
  dbms_output.put_line('METHODS');
  dbms_output.put_line('-------');
  dbms_output.put_line('Description: ' || obj.getDescription);
  dbms_output.put_line('MimeType: '|| obj.getMimeType);
EXCEPTION
  WHEN ordsys.ordaudioexceptions.description_is_not_set THEN
    dbms_output.put_line('Description: NOT SET');
END;
/

-- load audio files from disk to table
DECLARE
 obj1 ordsys.ordAudio;
 obj2 ordsys.ordAudio;
BEGIN
  SELECT audio
  INTO obj1
  FROM t_audio
  WHERE aid = 1
  FOR UPDATE;

  SELECT audio
  INTO obj2
  FROM t_audio
  WHERE aid = 2
  FOR UPDATE;

  obj1.setSource('FILE', 'AUDIODIR', '9_1_1.mp3');
  obj2.setSource('FILE', 'AUDIODIR', 'thing.wav');

  dbms_output.put_line(obj1.getSource);
  dbms_output.put_line(obj2.getSource);

  UPDATE t_audio
  SET audio=obj1
  WHERE aid=1;

  UPDATE t_audio
  SET audio=obj2
  WHERE aid=2;

  COMMIT;
END;
/

col descript format a40

SELECT t.aid, t.audio.getDescription() Descript
FROM t_audio t;

-- set description then invoke a method
DECLARE
 obj ordsys.ordaudio;
BEGIN
  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 1 FOR UPDATE;

  obj.setDescription('911 Phone Number');
  obj.setMimeType('audio/basic');

  dbms_output.put_line('Description: ' || obj.getDescription);
  dbms_output.put_line('MimeType: ' || obj.getMimeType);

  UPDATE t_audio
  SET audio = obj
  WHERE aid=1;

  SELECT audio
  INTO obj
  FROM t_audio
  WHERE aid = 2 FOR UPDATE;

  obj.setDescription('Always a Thing');
  obj.setMimeType('audio/x-wav');

  dbms_output.put_line('Description: ' || obj.getDescription);
  dbms_output.put_line('MimeType: ' || obj.getMimeType);

  UPDATE t_audio
  SET audio = obj
  WHERE aid=2;
  COMMIT;
EXCEPTION
  WHEN ordsys.ordaudioexceptions.description_is_not_set THEN
    dbms_output.put_line('Description: NOT SET');
END;
/

col mimetype format a40

SELECT t.aid, t.audio.getMimeType() MimeType
FROM t_audio t;

SELECT t.aid, t.audio.getContentLength() Content_Len
FROM t_audio t;

col src format a40
col location format a40
col srctype format a20

SELECT t.aid, t.audio.getSource() Src
FROM t_audio t;

SELECT t.aid, t.audio.getSourceLocation() Location
FROM t_audio t;

SELECT t.aid, t.audio.getSourceName() Location
FROM t_audio t;

SELECT t.aid, t.audio.getSourceType() SrcType
FROM t_audio t;

SELECT t.aid, t.audio.getUpdateTime()
FROM t_audio t;

SELECT t.aid, t.audio.getAllAttributes() All_Attributes
FROM t_audio t;

-- getAttribute
set linesize 80

DECLARE
 ctx    RAW(64);
 obj    ordsys.ordAudio;
 tmpLOB CLOB;
BEGIN
  SELECT t.audio
  INTO obj
  FROM t_audio t
  WHERE t.aid = 2;

  dbms_lob.createTemporary(tmpLOB, FALSE, dbms_lob.call);
  obj.getAllAttributes(ctx, tmpLOB);
  dbms_output.put_line(dbms_lob.substr(tmpLOB, dbms_lob.getLength(tmpLOB), 1));
EXCEPTION
  WHEN ordsys.ordAudioExceptions.audio_plugin_exception THEN
    RAISE;
END;
/

Related Topics
DBMS_LOB
DICOM
Oracle MultiMedia Image
Oracle MultiMedia Video
UTL_RAW

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2014 Daniel A. Morgan All Rights Reserved