Oracle interMedia User's Guide and Reference Release 9.0.1 Part Number A88786-01 |
|
Oracle interMedia contains information about the ORDDoc type:
The examples in this chapter assume that the test media table TDOC has been created and filled with data. This table was created using the SQL statements described in Section 7.3.1.
Methods invoked at the ORDSource level that are handed off to the source plug-in for processing have ctx(RAW(4000)) as the first argument. Before calling any of these methods for the first time, the client must allocate the ctx structure, initialize it to NULL, and invoke the openSource( ) method. At this point, the source plug-in can initialize context for this client. When processing is complete, the client should invoke the closeSource( ) method.
Methods invoked from a source plug-in call have the first argument as ctx (RAW(4000)).
Methods invoked at the ORDDoc level that are handed off to the format plug-in for processing have ctx (RAW(4000)) as the first argument. Before calling any of these methods for the first time, the client must allocate the ctx structure and initialize it to NULL.
You should use any of the individual set methods to set the value of the attribute for an object for formats not natively supported; otherwise, for formats natively supported, use the setProperties( ) method to populate the attributes of the object.
Oracle interMedia describes the ORDDoc object type, which supports the storage and management of any media data including text, image, audio, and video.
The ORDDoc object type supports the storage and management of media data. This object type is defined as follows:
CREATE OR REPLACE TYPE ORDDoc AS OBJECT ( -- ATTRIBUTES source ORDSource, format VARCHAR(80), mimeType VARCHAR(80), contentLength INTEGER, comments CLOB, -- METHODS -- CONSTRUCTORS -- STATIC FUNCTION init( ) RETURN ORDDoc, STATIC FUNCTION init(srcType IN VARCHAR2, srcLocation IN VARCHAR2, srcName IN VARCHAR2) RETURN ORDDoc, -- Methods associated with the mimeType attribute MEMBER FUNCTION getMimeType RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setMimeType(mime IN VARCHAR2), -- Methods associated with the date attribute MEMBER FUNCTION getUpdateTime RETURN DATE, PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setUpdateTime(current_time DATE), -- Methods associated with the format attribute MEMBER FUNCTION getFormat RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setFormat(format IN VARCHAR2), -- Methods associated with the source attribute MEMBER FUNCTION isLocal RETURN BOOLEAN, PRAGMA RESTRICT_REFERENCES(isLocal, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setLocal, MEMBER PROCEDURE clearLocal, MEMBER PROCEDURE setSource(source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER FUNCTION getSource RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceType RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceLocation RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS, WNPS, RNDS, RNPS), MEMBER FUNCTION getSourceName RETURN VARCHAR2, PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE setProperties(ctx IN OUT RAW, setComments IN BOOLEAN), MEMBER FUNCTION getBFILE RETURN BFILE, PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE import(ctx IN OUT RAW, set_prop IN BOOLEAN), MEMBER PROCEDURE importFrom(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2 set_prop IN BOOLEAN), MEMBER PROCEDURE export(ctx IN OUT RAW, source_type IN VARCHAR2, source_location IN VARCHAR2, source_name IN VARCHAR2), MEMBER FUNCTION openSource(userArg IN RAW, ctx OUT RAW) RETURN INTEGER, MEMBER FUNCTION closeSource(ctx IN OUT RAW) RETURN INTEGER, MEMBER FUNCTION trimSource(ctx IN OUT RAW, newlen IN INTEGER) RETURN INTEGER, MEMBER PROCEDURE readFromSource(ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer OUT RAW), MEMBER PROCEDURE writeToSource(ctx IN OUT RAW, startPos IN INTEGER, numBytes IN OUT INTEGER, buffer IN RAW), MEMBER FUNCTION getContentLength RETURN INTEGER, PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE getContentInLob(ctx IN OUT RAW, dest_lob IN OUT NOCOPY BLOB, mimeType OUT VARCHAR2, format OUT VARCHAR2), MEMBER FUNCTION getContent RETURN BLOB, PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS), MEMBER PROCEDURE deleteContent, MEMBER FUNCTION processSourceCommand(ctx IN OUT RAW, cmd IN VARCHAR2, arguments IN VARCHAR2, result OUT RAW) RETURN RAW );
where:
This section describes the constructor functions.
The interMedia constructor functions are as follows:
init( ) RETURN ORDDoc;
Allows for easy initialization of instances of the ORDDoc object type.
None.
None.
None.
This static method initializes all the ORDDoc attributes to NULL with the following exceptions:
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDDoc object type, especially if the ORDDoc type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Initialize the ORDDoc object attributes:
BEGIN INSERT INTO tdoc VALUES (1,ORDSYS.ORDDoc.init()); END; /
init(srcType IN VARCHAR2,
srcLocation IN VARCHAR2,
srcName IN VARCHAR2)
RETURN ORDDoc;
Allows for easy initialization of instances of the ORDDoc object type.
The source type of the media data.
The source location of the media data.
The source name of the mediamedia data.
None.
None.
This static method initializes all the ORDDoc attributes to NULL with the following exceptions:
You should begin using the init( ) method as soon as possible to allow you to more easily initialize the ORDDoc object type, especially if the ORDDoc type evolves and attributes are added in a future release. INSERT statements left unchanged using the default constructor (which initializes each object attribute), will fail under these circumstances.
Initialize the ORDDoc object attributes.
-- Create the DOCDIR load directory; this is the directory where the media -- files reside. CREATE OR REPLACE DIRECTORY docdir as 'e:\oracle\ord\doc\demo'; GRANT READ ON DIRECTORY docdir TO PUBLIC WITH GRANT OPTION; BEGIN INSERT INTO tdoc VALUES (2, ORDSYS.ORDDoc.init('file','DOCDIR','doc1.pdf'); END; /
This section presents reference information on the Oracle interMedia methods used for media data manipulation. These methods are described in the following groupings:
For more information on object types and methods, see Oracle9i Database Concepts.
The methods described in this reference chapter show examples based on a test media table TDOC. Refer to the TDOC table definition that follows when reading through the examples:
CREATE TABLE TDOC(n NUMBER CONSTRAINT n_pk PRIMARY KEY, doc ORDSYS.ORDDOC) STORAGE (INITIAL 100K NEXT 100K PCTINCREASE 0); INSERT INTO tdoc VALUES(1, ORDSYS.ORDDoc.init()); INSERT INTO tdoc VALUES(2, ORDSYS.ORDDoc.init());
getContentInLob(
ctx IN OUT RAW,
dest_lob IN OUT NOCOPY BLOB,
mimeType OUT VARCHAR2,
format OUT VARCHAR2);
Copies data from a data source into the specified BLOB. The BLOB must not be the BLOB in source.localData.
The source plug-in context information.
The LOB in which to receive data.
The MIME type of the data; this may or may not be returned.
The format of the data; this may or may not be returned.
None.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the getContentInLob( ) method and the value of srcType is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the getContentInLob( ) method and this method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the getContentInLob( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Get data from a data source and put it into the specified BLOB:
DECLARE obj ORDSYS.ORDDoc; tempBLob BLOB; mimeType VARCHAR2(4000); format VARCHAR2(4000); ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N = 1 ; if(obj.isLocal()) then DBMS_OUTPUT.put_line('local is true'); end if; DBMS_LOB.CREATETEMPORARY(tempBLob, true, 10); obj.getContentInLob(ctx,tempBLob, mimeType,format); DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.getLength(tempBLob))); EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('ORDSourceExceptions.METHOD_NOT_SUPPORTED caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
getContentLength RETURN INTEGER;
Returns the length of the media data content stored in the source.
None.
This method is not supported for all source types. For example, HTTP type sources do not support this method. If you want to implement this call for HTTP type sources, you must define your own modified HTTP source type and implement this method on it.
PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS,
WNPS, RNDS, RNPS)
None.
See the example in import( ).
getFormat RETURN VARCHAR2;
Returns the value of the format attribute of the media object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS)
INVALID_FORMAT_TYPE
This exception is raised if you call the getFormat( ) method and the value for format is NULL.
See the example in setProperties( ).
import(ctx IN OUT RAW
set_prop IN BOOLEAN);
Transfers media data from an external media data source to a local source (localData) within an Oracle database.
The source plug-in context information.This must be allocated. You must call the openSource( ) method; see the introduction to this chapter for more information.
If the value is TRUE, then the setProperties( ) method is called to read the media data to get the values of the object attributes and store them in the object attributes, otherwise, if the value is FALSE, the set Properties( ) method is not called. The default value is FALSE.
Use the setSource( ) method to set the external source type, location, and name prior to calling the import( ) method.
You must ensure that the directory exists or is created before you use this method.
After importing data from an external media data source to a local source (within an Oracle database), the source information remains unchanged (that is, pointing to the source from where the data was imported).
Invoking this method implicitly calls the setUpdateTime( ) and setLocal methods.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the import( ) method and the value of srcType is NULL.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the import( ) method and the value of dlob is NULL.
ORDSourceExceptionsMETHOD_NOT_SUPPORTED
This exception is raised if you call the import( ) method and the import( ) method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the import( ) method within a source plug-in when any other exception is raised.
ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION
This exception is raised if you call the import( ) method and the setProperties( ) method raises an exception from within the media plug-in.
See Appendix H for more information about these exceptions.
Import media data from an external media data source into the local source:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- set source to a file obj.setSource('file','DOCDIR','testdoc.dat'); -- get source information DBMS_OUTPUT.PUT_LINE(obj.getSource()); -- import data obj.import(ctx,FALSE); -- check size DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.getLength(obj.getContent()))); DBMS_OUTPUT.PUT_LINE(obj.getSource()); DBMS_OUTPUT.PUT_LINE('deleting contents'); DBMS_OUTPUT.PUT_LINE('-----------------'); obj.deleteContent(); DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.getLength(obj.getContent()))); UPDATE tdoc SET doc=obj WHERE N=1; COMMIT; EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.PUT_LINE('ORDSourceExceptions.METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('DOC PLUGIN EXCEPTION caught'); END; /
importFrom(ctx IN OUT RAW,
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2
set_prop IN BOOLEAN);
Transfers media data from the specified external media data source to a local source (localData) within an Oracle database.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see the introduction to this chapter for more information.
The source type of the media data.
The location from where the media data is to be imported.
The name of the media data.
If the value is TRUE, then the setProperties( ) method is called to read the media data to get the values of the object attributes and store them in the object attributes, otherwise, if the value is FALSE, the set Properties( ) method is not called. The default value is FALSE.
This method is similar to the import( ) method except the source information is specified as parameters to the method instead of separately.
You must ensure that the directory exists or is created before you use this method.
After importing data from an external media data source to a local source (within an Oracle database), the source information (that is, pointing to the source from where the data was imported) is set to the input values.
Invoking this method implicitly calls the setUpdateTime( ) and setLocal methods.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the import( ) method and the value of srcType is NULL.
ORDSourceExceptionsMETHOD_NOT_SUPPORTED
This exception is raised if you call the importFrom( ) method and this method is not supported by the source plug-in being used.
ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION
This exception is raised if you call the importFrom( ) method within a source plug-in when any other exception is raised.
ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION
This exception is raised if you call the import( ) method and the setProperties( ) method raises an exception from within the media plug-in.
See Appendix H for more information about these exceptions.
Import media data from the specified external data source into the local source:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N=1 FOR UPDATE FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- set source to a file -- import data obj.importFrom(ctx,'file','DOCDIR','testdoc.dat',FALSE); -- check size DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.GETLENGTH(obj.getContent()))); DBMS_OUTPUT.PUT_LINE(obj.getSource()); DBMS_OUTPUT.PUT_LINE('deleting contents'); DBMS_OUTPUT.PUT_LINE('-----------------'); obj.deleteContent(); DBMS_OUTPUT.PUT_LINE(TO_CHAR(DBMS_LOB.GETLENGTH(obj.getContent()))); UPDATE tdoc SET doc=obj WHERE N=1; COMMIT; EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.PUT_LINE('ORDSourceExceptions.METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('DOC PLUGIN EXCEPTION caught'); END; /
setFormat(knownFormat IN VARCHAR2);
Sets the format attribute of the media object.
The known format of the data to be set in the corresponding media object.
Calling this method implicitly calls the setUpdateTime( ) method.
None.
NULL_INPUT_VALUE
This exception is raised if you call the setFormat method and the value for the knownFormat parameter is NULL.
Set the format for some media data:
DECLARE obj ORDSYS.ORDDoc; BEGIN select doc into obj from tdoc where N =1 for update; obj.setFormat('PDF'); DBMS_OUTPUT.put_line('format: ' || obj.getformat()); COMMIT; EXCEPTION WHEN ORDSYS.ORDAudioExceptions.NULL_INPUT_VALUE THEN DBMS_OUTPUT.put_line('ORDSourceExceptions.NULL_INPUT_VALUE caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
setProperties(ctx IN OUT RAW,
setComments IN BOOLEAN);
Reads the media data to get the values of the object attributes and then stores them in the object attributes. This method sets the properties for the following attributes of the media data: format, MIME type, and content length. It populates the comments field of the object with an extensive set of format and application properties in XML form if the value of the setComments parameter is TRUE.
Note: Some audio, image, and video formats are supported, but no media formats are supported. This method works for only natively supported formats. See Appendix A, Appendix B, and Appendix C for information on natively supported media formats. |
The format plug-in context information.
If the value is TRUE, then the comments field of the object is populated with an extensive set of format and application properties of the media object in XML form, identical to what is provided by the interMedia Annotator utility; otherwise, if the value is FALSE, the comments field of the object remains unpopulated. The default value is FALSE.
If the property cannot be extracted from the media source, then the respective attribute is set to NULL.
If the format is set to NULL, then the setProperties( ) method uses the default format plug-in; otherwise, it uses the plug-in specified by the format.
None.
DOC_PLUGIN_EXCEPTION
This exception is raised if you call the setProperties( ) method and the media plug-in raises an exception.
Example 1: Set the property information for known media attributes:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N =1 FOR UPDATE; obj.setProperties(ctx,FALSE); --DBMS_OUTPUT.put_line('format: ' || obj.getformat()); UPDATE tdoc SET doc = obj WHERE N =1 ; COMMIT; EXCEPTION
WHEN ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('DOC PLUGIN EXCEPTION caught');
WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
Example 2: Set the property information for known media attributes and store the format and application properties in the comments attribute. Create an extensible index on the contents of the comments attribute using Oracle Text.
DECLARE obj ORDSYS.ORDDoc; ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N =1 FOR UPDATE; obj.setProperties(ctx,TRUE); --DBMS_OUTPUT.put_line('format: ' || obj.getformat()); UPDATE tdoc SET doc = obj WHERE N =1 ; COMMIT; EXCEPTION
WHEN ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('DOC PLUGIN EXCEPTION caught');
WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; / -- Must have interMedia text installed on your system. CREATE INDEX mediaindex ON tdoc(doc.comments) INDEXTYPE IS ctxsys.context;
This section presents reference information on the packages or PL/SQL plug-ins provided. Table 7-1 describes the PL/SQL plug-in packages provided in the ORDPLUGINS schema.
PL/SQL Plug-in Packages | Media Format | MIME Type |
---|---|---|
ORDPLUGINS.ORDX_DEFAULT_DOC |
<format> |
Dependent on file format |
Section 7.4.1 describes the ORDPLUGINS.ORDX_DEFAULT_DOC package, the method supported, and the level of support. The method supported and the level of support for the PL/SQL plug-in package is described in Table 7-2.
Use the following provided ORDPLUGINS.ORDX_DEFAULT_DOC package as a guide in developing your own ORDPLUGINS.ORDX_<format>_DOC media format package. This package sets the mimeType field in the setProperties( ) method with a MIME type value that is dependent on the file format.
CREATE OR REPLACE PACKAGE ORDX_DEFAULT_DOC authid current_user AS PROCEDURE setProperties(ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDDoc, setComments IN NUMBER := 0); END; /
Table 7-2 shows the method supported in the ORDPLUGINS.ORDX_DEFAULT_DOC package and the exception raised if the source is null.
Extending interMedia to support a new media data format consists of four steps:
Section 3.2.11 briefly describes how to extend interMedia to support a new media data format and describes the interface. A package body listing is provided in Example 7-1 to assist you in this operation. Add your variables to the places that say "--Your variables go here" and add your code to the places that say "--Your code goes here".
See Section F.2 for more information on installing your own media format plug-in and running the sample scripts provided.
CREATE OR REPLACE PACKAGE BODY ORDX_MY_DOC AS --DOCUMENT ATTRIBUTES ACCESSORS PROCEDURE setProperties(ctx IN OUT RAW, obj IN OUT NOCOPY ORDSYS.ORDDoc, setComments IN NUMBER :=FALSE) IS --Your variables go here BEGIN --Your code goes here END; END; / show errors;
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|