Created
January 18, 2013 09:48
-
-
Save heyLu/4563501 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
drop table sounds; | |
drop table videos; | |
create table sounds ( | |
id number constraint sounds_pk primary key, | |
sound ordsys.ORDAudio | |
); | |
create or replace directory AUDIODIR as '/home/lstadler/oracle'; | |
DECLARE | |
TYPE strArray IS VARRAY(4) OF VARCHAR(20); | |
-- application variables | |
audioObj ORDSYS.ORDAudio; | |
ctx RAW(4000) := NULL; | |
fileNames strArray; | |
BEGIN | |
fileNames := strArray( '1.mp3', '2.mp3', '3.mp3' ); | |
FOR I IN 1..3 LOOP | |
INSERT INTO sounds | |
VALUES ( I, ORDSYS.ORDAudio.init() ); | |
-- Select the newly inserted row for update | |
SELECT sound INTO audioObj FROM sounds WHERE id = I for UPDATE; | |
-- fill in the audio BLOB. | |
-- This example imports the audio file from the AUDDIR | |
-- directory on a local file system | |
-- (srcType=FILE) and automatically sets the properties. | |
audioObj.setSource('file','AUDIODIR',fileNames(I)); | |
audioObj.import(ctx); | |
audioObj.setProperties(ctx); | |
UPDATE sounds SET sound = audioObj WHERE id = I; | |
END LOOP; | |
COMMIT; | |
-- Continue processing | |
END; | |
/ | |
select id, s.sound.getMimeType() as mimetype, s.sound.getEncoding() as encoding | |
from sounds s where id = 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment