Oracle® interMedia Reference 10g Release 1 (10.1) Part Number B10829-01 |
|
|
View PDF |
This section presents reference information on the interMedia methods used specifically for media data manipulation.
Chapter 3 presents reference information on the interMedia methods that are common to ORDAudio, ORDDoc, ORDImage, and ORDVideo. Use the methods presented in both chapters to get and set attributes, and to perform metadata extractions.
For more information on object types and methods, see Oracle Database Concepts.
Format
getContentInLob(
ctx IN OUT RAW,
dest_lob IN OUT NOCOPY BLOB,
mimeType OUT VARCHAR2,
format OUT VARCHAR2);
Description
Copies data from a data source into the specified BLOB. The BLOB must not be the BLOB in the source.localData attribute (of the embedded ORDSource object).
Parameters
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.
Usage Notes
None.
Pragmas
None.
Exceptions
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 and the source plug-in raises an exception.
See Appendix F for more information about these exceptions.
Examples
Get data from a data source and put it into the specified BLOB:
DECLARE obj ORDSYS.ORDDoc; tempBLob BLOB; mimeType VARCHAR2(4000); format VARCHAR2(31); ctx RAW(64) :=NULL; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2808 ; 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('Length: ' || 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; /
Format
getContentLength( ) RETURN INTEGER;
Description
Returns the length of the media data content stored in the source.
Parameters
None.
Usage Notes
None.
Pragmas
PRAGMA RESTRICT_REFERENCES(getContentLength, WNDS,
WNPS, RNDS, RNPS)
Exceptions
None.
Examples
DECLARE obj ORDSYS.ORDDoc; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2808 ; IF (obj.isLocal()) THEN DBMS_OUTPUT.put_line('Local is true'); END IF; DBMS_OUTPUT.PUT_LINE('Content length is ' || TO_CHAR(obj.getContentLength)); END;/
Format
getFormat( ) RETURN VARCHAR2;
Description
Returns the value of the format attribute of the media object.
Parameters
None.
Usage Notes
None.
Pragmas
PRAGMA RESTRICT_REFERENCES(getFormat, WNDS, WNPS, RNDS, RNPS)
Exceptions
ORDDocExceptions.INVALID_FORMAT_TYPE
This exception is raised if you call the getFormat( ) method and the value of the format attribute is NULL.
Examples
See the example in setFormat( ).
Format
import(ctx IN OUT RAW
set_prop IN BOOLEAN);
Description
Transfers media data from an external media data source to the source.localData attribute (of the embedded ORDSource object) within the database.
Parameters
The source plug-in context information. This should be allocated and initialized to NULL. If you are using a user-defined source plug-in, you should call the openSource( ) method. See the introduction to this chapter for more information.
A value that determines whether the setProperties( ) method is called. If the value of this parameter 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.
Usage Notes
Use the setSource( ) method to set the source.srcType, source.srcLocation, and source.Name attributes (of the embedded ORDSource object) for the external media data source prior to calling the import( ) method.
After importing data from an external media data source to a local source (within 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.
This method is invoked at the ORDSource level, which uses the PL/SQL UTL_HTTP package to import media data from an HTTP data source. You can use environment variables to specify the proxy behavior of the UTL_HTTP package. For example, on UNIX, setting the environment variable http_proxy to a URL specifies that the UTL_HTTP package will use that URL as the proxy server for HTTP requests. Setting the no_proxy environment variable to a domain name specifies that the HTTP proxy server will not be used for URLs in the specified domain.
See PL/SQL Packages and Types Reference for more information about the UTL_HTTP PL/SQL package.
Pragmas
None.
Exceptions
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the import( ) method and the value of the source.srcType attribute is NULL.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the import( ) method and the value of the source.localData attribute is NULL.
ORDSourceExceptions.METHOD_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 and the source plug-in raises an exception.
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 F for more information about these exceptions.
Examples
Import media data from an external media data source into the local source:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(64) :=NULL; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2808 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); -- set source to a file obj.setSource('file','FILE_DIR','printer.rm'); -- get source information DBMS_OUTPUT.PUT_LINE(obj.getSource()); -- import data obj.import(ctx,FALSE); -- check size DBMS_OUTPUT.PUT_LINE('Length:' ||TO_CHAR(DBMS_LOB.getLength(obj.getContent))); UPDATE pm.online_media SET product_testimonials=obj WHERE product_id=2808; 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; /
Format
importFrom(ctx IN OUT RAW,
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2
set_prop IN BOOLEAN);
Description
Transfers media data from the specified external media data source to the source.localData attribute (of the embedded ORDSource object) within the database).
Parameters
The source plug-in context information. This should be allocated and initialized to NULL. If you are using a user-defined source plug-in, you should call the openSource( ) method. See the introduction to this chapter for more information.
The type of the source media data.
The location from which the source media data is to be imported.
The name of the source media data.
A value that determines whether the setProperties( ) method is called. If the value of this parameter 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.
Usage Notes
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 indicated by the source_location parameter exists or is created before you use this method.
After importing data from an external media data source to a local source (within 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.
This method is invoked at the ORDSource level, which uses the PL/SQL UTL_HTTP package to import media data from an HTTP data source. You can use environment variables to specify the proxy behavior of the UTL_HTTP package. For example, on UNIX, setting the environment variable http_proxy to a URL specifies that the UTL_HTTP package will use that URL as the proxy server for HTTP requests. Setting the no_proxy environment variable to a domain name specifies that the HTTP proxy server will not be used for URLs in the specified domain.
See PL/SQL Packages and Types Reference for more information about the UTL_HTTP PL/SQL package.
Pragmas
None.
Exceptions
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the importFrom( ) method and the value of the source_type parameter is NULL.
ORDSourceExceptions.METHOD_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 and the source plug-in raises an exception.
ORDSYS.ORDDocExceptions.DOC_PLUGIN_EXCEPTION
This exception is raised if you call the importFrom( ) method and the setProperties( ) method raises an exception from within the media plug-in.
See Appendix F for more information about these exceptions.
Examples
Import media data from the specified external data source into the local source:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(64) :=NULL; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id=2999 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','FILE_DIR','modem.jpg',FALSE); -- check size DBMS_OUTPUT.PUT_LINE('Length: '||TO_CHAR(DBMS_LOB.GETLENGTH(obj.getContent))); DBMS_OUTPUT.PUT_LINE(obj.getSource()); UPDATE pm.online_media SET product_testimonials=obj WHERE product_id=2999; 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; /
Format
setFormat(knownFormat IN VARCHAR2);
Description
Sets the format attribute of the media object.
Parameters
The known format of the data to be set in the corresponding media object.
Usage Notes
Calling this method implicitly calls the setUpdateTime( ) method.
Pragmas
None.
Exceptions
ORDDocExceptions.NULL_INPUT_VALUE
This exception is raised if you call the setFormat( ) method and the value for the knownFormat parameter is NULL.
Examples
Set the format for some media data:
DECLARE obj ORDSYS.ORDDoc; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2808 FOR UPDATE; obj.setFormat('PDF'); DBMS_OUTPUT.put_line('format: ' || obj.getformat()); COMMIT; EXCEPTION WHEN ORDSYS.ORDDocExceptions.NULL_INPUT_VALUE THEN DBMS_OUTPUT.put_line('ORDDocExceptions.NULL_INPUT_VALUE caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('EXCEPTION caught'); END; /
Format
setProperties(ctx IN OUT RAW,
setComments IN BOOLEAN);
Description
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: This method works for only natively supported audio, image, and video formats. See Appendix A, Appendix B, and Appendix C for information on natively supported audio, image, and video formats. |
Parameters
The format plug-in context information.
A Boolean value that indicates whether or not the comments field of the object is populated. 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; otherwise, if the value is FALSE, the comments field of the object remains unpopulated. The default value is FALSE.
Usage Notes
If the property cannot be extracted from the media source, then the respective attribute is set to NULL.
If the format attribute is set to NULL, then the setProperties( ) method uses the default format plug-in; otherwise, it uses the plug-in specified by the format.
Pragmas
None.
Exceptions
ORDDocExceptions.DOC_PLUGIN_EXCEPTION
This exception is raised if you call the setProperties( ) method and the media plug-in raises an exception.
Examples
Set the property information for known media attributes:
DECLARE obj ORDSYS.ORDDoc; ctx RAW(64) :=NULL; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2808 FOR UPDATE; obj.setProperties(ctx,FALSE); DBMS_OUTPUT.put_line('format: ' || obj.getformat()); UPDATE pm.online_media SET product_testimonials = obj WHERE product_id=2808; 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; /
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(64) :=NULL; BEGIN SELECT product_testimonials INTO obj FROM pm.online_media WHERE product_id = 2999 FOR UPDATE; obj.setProperties(ctx,TRUE); DBMS_OUTPUT.put_line('format: ' || obj.getformat()); UPDATE pm.online_media SET product_testimonials = obj WHERE product_id=2999; 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; / CONNECT / AS SYSDBA -- Must have Oracle Text installed on your system. CREATE INDEX mediaindex ON pm.online_media(product_testimonials.comments) INDEXTYPE IS ctxsys.context;