4 Oracle Multimedia ORD_DOC PL/SQL Package

Oracle Multimedia provides the ORD_DOC PL/SQL package. This package provides procedures to perform common operations such as importing and exporting media data to and from operating system files, and extracting information from media data.

This package adds Oracle Multimedia support to audio, image, video, and other heterogeneous media data stored in BLOBs and BFILEs.

The ORD_DOC package is defined in the orddrpsp.sql file. After installation, this file is available in the Oracle home directory at:

<ORACLE_HOME>/ord/im/admin (on Linux and UNIX)

<ORACLE_HOME>\ord\im\admin (on Windows)

The examples in these topics assume that the DOCDIR directory and these tables exist: TAUD, TDOC, TIMG, and TVID.

See the following topics for details about the procedures in the ORD_DOC PL/SQL package:

See Also:

4.1 ORD_DOC PL/SQL Package: getProperties( ) for BFILEs

Format

getProperties(docBfile   IN OUT NOCOPY BFILE, 
              attributes IN OUT NOCOPY CLOB);

Description

Reads the document data stored in a BFILE to get the values of the media attributes for supported formats, and then stores them in the input CLOB. This procedure populates the CLOB with a set of format and application properties in XML form.

Parameters

docBfile

The document data represented as a BFILE.

attributes

The CLOB to hold the XML attribute information extracted by the getProperties( ) procedure. This CLOB is populated with a set of format and application properties of the document BFILE data in XML form.

Usage Notes

None.

Pragmas

None.

Exceptions

None.

Examples

Get the property information for known document attributes:

DECLARE
   doc_attrib CLOB;
   doc_data BFILE:=BFILENAME('DOCDIR','testvid.dat');
BEGIN
   DBMS_LOB.CREATETEMPORARY(doc_attrib, FALSE, DBMS_LOB.CALL);

   -- get properties from bfile
   ORDSYS.ORD_DOC.getProperties(doc_data, doc_attrib);

   -- print length of extracted properties
   DBMS_OUTPUT.PUT_LINE('Size of XML Annotations ' ||
        TO_CHAR(DBMS_LOB.GETLENGTH(doc_attrib)));

EXCEPTION
   WHEN OTHERS THEN
        RAISE;
END;
/

4.2 ORD_DOC PL/SQL Package: getProperties( ) (all attributes) for BFILEs

Format

getProperties(docBfile      IN OUT NOCOPY BFILE, 
              mimeType      OUT VARCHAR2, 
              format        OUT VARCHAR2, 
              contentLength OUT INTEGER);

Description

Reads the document data stored in a BFILE to get the values of the media attributes for supported formats, and then returns them as explicit parameters. This procedure extracts the properties for these attributes of the document data: MIME type, content length, and format.

Parameters

docBfile

The document data represented as a BFILE.

mimeType

The MIME type of the document data.

format

The format of the document data.

contentLength

The length of the content, in bytes.

Usage Notes

If a property cannot be extracted from the media source, then the respective parameter is set to NULL.

Pragmas

None.

Exceptions

None.

Examples

Get the property information for known document attributes:

DECLARE
   doc_data BFILE:=BFILENAME('DOCDIR','testimg.dat');
   doc_mimeType VARCHAR2(80);
   doc_format VARCHAR2(32):=NULL;
   doc_contentLength NUMBER;
BEGIN

   -- get properties from bfile
   ORDSYS.ORD_DOC.getProperties(doc_data,
        doc_mimeType, doc_format, doc_contentLength);

   -- print properties
   DBMS_OUTPUT.PUT_LINE('mimeType: ' || doc_mimeType );
   DBMS_OUTPUT.PUT_LINE('format: ' || doc_format );
   DBMS_OUTPUT.PUT_LINE('contentLength: ' || doc_contentLength );

EXCEPTION
   WHEN OTHERS THEN
        RAISE;
END;
/

4.3 ORD_DOC PL/SQL Package: getProperties( ) for BLOBs

Format

getProperties(docBlob    IN BLOB, 
              attributes IN OUT NOCOPY CLOB);

Description

Reads the document data stored in a BLOB to get the values of the media attributes for supported formats, and then stores them in the input CLOB. This procedure extracts the properties for these attributes of the document data: MIME type, content length, and format. This procedure populates the CLOB with a set of format and application properties in XML form.

Parameters

docBlob

The document data represented as a BLOB.

attributes

The CLOB to hold the XML attribute information extracted by the getProperties( ) procedure. This CLOB is populated with a set of format and application properties of the document BLOB data in XML form.

Usage Notes

None.

Pragmas

None.

Exceptions

ORDSourceExceptions.EMPTY_SOURCE

This exception is raised when the input docBLOB parameter is NULL.

Examples

Get the property information for known document attributes:

DECLARE
   doc_attrib CLOB;
   doc_data BLOB;
BEGIN
   SELECT document,attributes INTO doc_data,doc_attrib 
       FROM tdoc WHERE N=1 FOR UPDATE;

   -- get properties from blob 
   ORDSYS.ORD_DOC.getProperties(doc_data, doc_attrib);
  
   -- print length of extracted properties
   DBMS_OUTPUT.PUT_LINE('Size of XML Annotations ' ||
        TO_CHAR(DBMS_LOB.GETLENGTH(doc_attrib)));

   UPDATE tdoc SET document=doc_data, attributes=doc_attrib WHERE N=1;
   COMMIT;

EXCEPTION
   WHEN OTHERS THEN
        RAISE;
END;
/

4.4 ORD_DOC PL/SQL Package: getProperties( ) (all attributes) for BLOBs

Format

getProperties(docBLOB       IN BLOB, 
              mimeType      OUT VARCHAR2, 
              format        OUT VARCHAR2, 
              contentLength OUT INTEGER);

Description

Reads the document data stored in a BLOB to get the values of the media attributes for supported formats, and then returns them as explicit parameters. This procedure extracts the properties for these attributes of the document data: MIME type, content length, and format.

Parameters

docBLOB

The document data represented as a BLOB.

mimeType

The MIME type of the document data.

format

The format of the document data.

contentLength

The length of the content, in bytes.

Usage Notes

If a property cannot be extracted from the media source, then the respective parameter is set to NULL.

Pragmas

None.

Exceptions

ORDSourceExceptions.EMPTY_SOURCE

This exception is raised when the input docBLOB parameter is NULL.

Examples

Get the property information for known document attributes:

DECLARE
   doc_data BLOB;
   doc_mimeType VARCHAR2(80);
   doc_format VARCHAR2(32):=NULL;
   doc_contentLength NUMBER;
BEGIN
   SELECT document, mimetype, format, contentlength 
       INTO doc_data, doc_mimeType, doc_format, doc_contentLength 
       FROM tdoc WHERE N=1 FOR UPDATE;

   -- get properties from blob
   ORDSYS.ORD_DOC.getProperties(doc_data, doc_mimeType, doc_format, 
       doc_contentLength);

   -- print properties
   DBMS_OUTPUT.PUT_LINE('mimeType: ' || doc_mimeType );
   DBMS_OUTPUT.PUT_LINE('format: ' || doc_format );
   DBMS_OUTPUT.PUT_LINE('contentLength: ' || doc_contentLength );

   UPDATE tdoc SET
         document=doc_data,
         mimetype=doc_mimeType,
         format=doc_format,
         contentlength=doc_contentLength
       WHERE N=1;
   COMMIT;

EXCEPTION
   WHEN OTHERS THEN
        RAISE;
END;
/