Dr. Dobb's Journal - February 2009 - (Page 30) d02will_p1db 12/12/08 10:31 AM Page 30 State of the Art VIDEOS AND ORACLE FORMS 10G Listing One CREATE TABLE MULTIMEDIA ( ID INTEGER, THEBLOB BLOB, FILE_NAME VARCHAR2(50 BYTE) NOT NULL, MIME_TYPE VARCHAR2(20 BYTE) NOT NULL ) TABLESPACE table_DATA1 LOGGING NOCOMPRESS LOB (THEBLOB) STORE AS ( TABLESPACE table_DATA2 ENABLE STORAGE IN ROW CHUNK 8192 RETENTION NOCACHE INDEX ( TABLESPACE table_index1 ) ) NOCACHE NOPARALLEL NOMONITORING; To store videos, you need a datatype that can hold the video Listing Two DROP DIRECTORY DOCHOME; CREATE OR REPLACE DIRECTORY DOCHOME AS '/u03/docHome'; Listing Three CREATE OR REPLACE PROCEDURE load_multimedia as l_blob blob; l_bfile bfile; begin insert into multimedia values ( 1, empty_blob(),'Gulfport.wmv' ,'video/x-ms-wmv' ) returning theblob into l_blob; l_bfile := bfilename('DOCHOME','Gulfport.wmv'); dbms_lob.fileopen(l_bfile); dbms_lob.loadfromfile( l_blob, l_bfile, dbms_lob.getlength( l_bfile) ); dbms_lob.fileclose(l_bfile); end; / continued from page 28 Creating a Stored Procedure The show_video() procedure displays videos. This procedure must be called from the web browser using a Database Access Descriptor (DAD) from your HTTP Server. I ran across this procedure (created by Brian Hill) in the OTN Reports Forum. However, I customized it for my needs; see Listing Four. In this procedure, the select statement selects the filename, mime type, and video (Blob), while the table ID equals the parameter passed in with the procedure. I use the HTP package to display a header on the web page. The HTP package consists of a set of procedures and functions to embed HTML inside PL/SQL code. The package WPG_Docload.Download_File() downloads a Blob datatype into a browser; in this case, display the video on the web page. Listing Four CREATE OR REPLACE PROCEDURE show_video (p_file_number IN NUMBER) AS l_file_name multimedia.file_name%TYPE; l_mime_type multimedia.mime_type%TYPE; l_blob_handle BLOB; BEGIN SELECT file_name, mime_type, theblob INTO l_file_name, l_mime_type, l_blob_handle FROM multimedia WHERE ID = p_file_number; -- build an http header that includes mime type and length OWA_UTIL.mime_header (NVL (l_mime_type, 'application/octet'), FALSE); HTP.p ('Content-length: ' DBMS_LOB.getlength (l_blob_handle)); HTP.p ('Content-Disposition: file_name="' l_file_name '"'); OWA_UTIL.http_header_close; -- download the file WPG_Docload.Download_File (l_blob_handle); EXCEPTION WHEN OTHERS THEN HTP.p (SQLCODE SQLERRM); END show_video; / Creating a Database Access Descriptor (DAD) According to MetaGlossary.com a database access descriptor (DAD) “is a set of values that specify how an application connects to 30 Dr. Dobb’s Journal l www.ddj.com l February 2009 http://www.MetaGlossary.com http://www.ddj.com
Table of Contents Feed for the Digital Edition of Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 Contents Friday Night Fish Fry Alia Vox Developer Diaries Conversations Computing in the Clouds Software Development in the Cloud Videos and Oracle Forms 10g Parallel LINQ Decoupling C Header Files Effective Concurrency Disciplined Agility Swaine’s Flames Dr. Dobb's Journal - February 2009 Dr. Dobb's Journal - February 2009 - (Page BB1) Dr. Dobb's Journal - February 2009 - (Page BB2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page Cover2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 1) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 2) Dr. Dobb's Journal - February 2009 - Dr. Dobb's Journal - February 2009 (Page 3) Dr. Dobb's Journal - February 2009 - Contents (Page 4) Dr. Dobb's Journal - February 2009 - Contents (Page 5) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 6) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 7) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 8) Dr. Dobb's Journal - February 2009 - Friday Night Fish Fry (Page 9) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 10) Dr. Dobb's Journal - February 2009 - Alia Vox (Page 11) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 12) Dr. Dobb's Journal - February 2009 - Developer Diaries (Page 13) Dr. Dobb's Journal - February 2009 - Conversations (Page 14) Dr. Dobb's Journal - February 2009 - Conversations (Page 15) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 16) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 17) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 18) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 19) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 20) Dr. Dobb's Journal - February 2009 - Computing in the Clouds (Page 21) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 22) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 23) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 24) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 25) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 26) Dr. Dobb's Journal - February 2009 - Software Development in the Cloud (Page 27) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 28) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 29) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 30) Dr. Dobb's Journal - February 2009 - Videos and Oracle Forms 10g (Page 31) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 32) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 33) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 34) Dr. Dobb's Journal - February 2009 - Parallel LINQ (Page 35) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 36) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 37) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 38) Dr. Dobb's Journal - February 2009 - Decoupling C Header Files (Page 39) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 40) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 41) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 42) Dr. Dobb's Journal - February 2009 - Effective Concurrency (Page 43) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 44) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 45) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 46) Dr. Dobb's Journal - February 2009 - Disciplined Agility (Page 47) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page 48) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover3) Dr. Dobb's Journal - February 2009 - Swaine’s Flames (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.