Oracle interMedia User's Guide and Reference Release 9.0.1 Part Number A88786-01 |
|
This chapter presents reference information on the common methods used for the following Oracle interMedia data types:
See Section 5.2 for a list of methods described in this chapter.
The examples in this chapter assume that you have created the test tables as described in Section 6.3.1, Section 7.3.1, Section 8.1.3, and Section 9.3.1.
Methods invoked at the ORDSource level that are handed off to a 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 at the ORDAudio, ORDDoc, or ORDVideo level that are handed off to a 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.
For ORDAudio, ORDDoc, or ORDVideo object types, you should use any of the individual set methods to set the value of the attribute for an object for formats not natively supported or write a format plug-in and call setProperties( ); otherwise, for formats natively supported, use the setProperties( ) method to populate the attributes of the object.
For ORDImage object types, use the setProperties( ) method to populate the attributes of the object. Use the setProperties( ) for Foreign Images method for foreign image formats.
This section presents reference information on the Oracle interMedia methods that are common to all object types. These common methods are described in the following groupings. Other methods, which are particular to a particular object type or which are implemented differently for the different object types, are described in Section 6.3, Section 7.3, Section 8.1.2, and Section 9.3.
For more information on object types and methods, see Oracle9i Database Concepts.
clearLocal( );
Resets the local flag to indicate that the data is stored externally. When the local flag is set to clear, media methods look for corresponding data using the srcLocation, srcName, and srcType attributes.
None.
This method sets the local attribute to a 0, meaning the data is stored externally or outside of Oracle9i.
None.
None.
Clear the value of the local flag for the data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N = 1 FOR UPDATE; obj.clearLocal(); UPDATE TAUD SET aud=obj WHERE N = 1; COMMIT; END; /
closeSource(ctx IN OUT RAW) RETURN INTEGER;
Closes a data source.
The source plug-in context information. You must call the openSource( ) method; see Section 5.1 for more information.
The return INTEGER is 0 (zero) for success and >0 (for example, 1) for failure. The exact number and the meaning for that number is plug-in defined. For example, for the file plug-in, 1 might mean "File not found," 2 might mean "No such directory," and so forth.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the closeSource( ) method and the value for srcType is NULL and data is not local.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the closeSource( ) 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 closeSource( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Close an external data source:
DECLARE obj ORDSYS.ORDAudio; res INTEGER; ctx RAW(4000) :=NULL; BEGIN SELECT aud INTO obj FROM taud WHERE N =2 FOR UPDATE; res := obj.closeSource(ctx); UPDATE TAUD SET aud=obj WHERE N=2 ; COMMIT; 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; /
deleteContent( );
Deletes the local data from the current local source (localData).
None.
This method can be called after you export the data from the local source to an external data source and you no longer need this data in the local source.
Call this method when you want to update the object with a new object.
None.
None.
Delete the local data from the current local source:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe' FOR UPDATE; -- delete the local content of the image Image.deleteContent(); UPDATE emp SET large_photo = Image WHERE ename = 'John Doe'; END; /
export(
ctx IN OUT RAW,
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2);
Copies data from a local source (localData) within an Oracle database to a corresponding external data source.
Note: The export( ) method natively supports only sources of source type file. User-defined sources may support the export( ) method. |
The source plug-in context information.
The source type of the location to where the data is to be exported.
The location where the data is to be exported.
The name of the object to where the data is to be exported.
After exporting data, all attributes remain unchanged and srcType, srcLocation, and srcName are updated with input values. After calling the export( ) method, you can call the clearLocal( ) method to indicate the data is stored outside the database and call the deleteContent( ) method if you want to delete the content of the local data.
This method is also available for user-defined sources that can support the export method.
The export( ) method for a source type of file is similar to a file copy operation in that the original data stored in the BLOB is not touched other than for reading purposes.
The export( ) method is not an exact mirror operation to the import( ) method in that the clearLocal( ) method is not automatically called to indicate the data is stored outside the database, whereas the import( ) method automatically calls the setLocal( ) method.
Call the deleteContent( ) method after calling the export( ) method to delete the content from the database if you no longer intend to manage the multimedia data within the database.
The export( ) method writes only to a directory object that the user has privilege to access. That is, you can access a directory that you have created using the SQL CREATE DIRECTORY statement, or one to which you have been granted READ access. To execute the CREATE DIRECTORY statement, you must have the CREATE ANY DIRECTORY privilege. In addition, you must use the DBMS_JAVA.GRANT_PERMISSION call to specify which files can be written.
For example, the following grants the user, MEDIAUSER, the permission to write to the file named filename.dat:
CALL DBMS_JAVA.GRANT_PERMISSION( 'MEDIAUSER', 'java.io.FilePermission', '/actual/server/directory/path/filename.dat', 'write');
See the security and performance section in Oracle9i Java Developer's Guide for more information.
Invoking this method implicitly calls the setUpdateTime( ) method.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the export( ) method and the value of srcType is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the export( ) 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 export( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
ORDSourceExceptions.IO_ERROR
This exception is raised if the export( ) method encounters an error writing the BLOB data to the file specified.
Export data from a local source to an external data source.
-- Create the directory to which you -- want to export your files. CREATE OR REPLACE DIRECTORY docdir as 'e:\<ORACLE_HOME>\ord\doc\demo'; GRANT READ ON DIRECTORY docdir TO PUBLIC WITH GRANT OPTION; SET ECHO ON; SET SERVEROUTPUT ON; CONNECT SYSTEM AS SYSDBA; BEGIN DBMS_JAVA.GRANT_PERMISSION('PUBLIC', 'java.io.FilePermission', 'e:\ORACLE_ HOME>\ord\doc\demo\testdoc.dat', 'WRITE'); COMMIT; END; / DECLARE obj ORDSYS.ORDDoc; ctx RAW(4000) :=NULL; BEGIN SELECT doc INTO obj FROM tdoc WHERE N = 1 FOR UPDATE; obj.export(ctx,'file','DOCDIR','testdoc.dat'); EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('Source METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('SOURCE PLUGIN EXCEPTION caught'); WHEN OTHERS THEN DBMS_OUTPUT.put_line('OTHER EXCEPTION caught'); END; /
getBFILE( ) RETURN BFILE;
Returns the LOB locator of the BFILE containing the media.
None.
This method constructs and returns a BFILE using the stored source.srcLocation and source.srcName attribute information. The source.srcLocation attribute must contain a defined directory object. The source.srcName attribute must be a valid file name and source.srcType must be "file".
PRAGMA RESTRICT_REFERENCES(getBFILE, WNDS, WNPS, RNDS, RNPS)
If the source.srcType attribute value is NULL, calling this method raises an INCOMPLETE_SOURCE_INFORMATION exception.
If the value of srcType is other than file, then calling this method raises an INVALID_SOURCE_TYPE exception.
Return the BFILE for the stored source directory and file name attributes:
DECLARE obj ORDSYS.ORDVideo; videobfile BFILE; BEGIN SELECT vid INTO obj FROM tvid WHERE N=1; -- get the video BFILE videobfile := obj.getBFILE(); END; /
getContent( ) RETURN BLOB;
Returns a handle to the local BLOB storage, that is the BLOB within the object.
None.
None.
PRAGMA RESTRICT_REFERENCES(getContent, WNDS, WNPS, RNDS, RNPS)
None.
A client accesses video data to be put on a Web-based player:
DECLARE obj ORDSYS.ORDVideo; BEGIN SELECT vid INTO obj FROM TVID WHERE N=1 FOR UPDATE; -- import data obj.importFrom(ctx,'file','VIDEODIR','MV1.AVI'); -- check size DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); 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(obj.getContentLength(ctx))); UPDATE TVID SET vid=obj WHERE N=1; COMMIT; END; /
getMimeType( ) RETURN VARCHAR2;
Returns the MIME type for the data. This is a simple access method that returns the value of the mimeType attribute.
None.
If the source is an HTTP server, the MIME type information is read from the HTTP header information when the media is imported and stored in the object attribute. If the source is a file or BLOB, the MIME type information is extracted when the setProperties( ) method is called.
For unrecognized file formats, users must call the setMimeType( ) method and specify the MIME type.
Use this method rather than accessing the mimeType attribute directly to protect yourself from potential changes to the internal representation of the object.
PRAGMA RESTRICT_REFERENCES(getMimeType, WNDS, WNPS, RNDS, RNPS)
None.
Set the MIME type for some stored image data:
DECLARE Image ORDSYS.ORDImage; BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- set the image mime type Image.setMimeType('image/myformat'); END; /
getSource( ) RETURN VARCHAR2;
Returns information about the external location of the data in URL format.
None.
Possible return values are:
PRAGMA RESTRICT_REFERENCES(getSource, WNDS, WNPS, RNDS, RNPS)
None.
Get the source of the image data:
DECLARE Image ORDSYS.ORDImage; SourceInfo VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source information SourceInfo := Image.getSource(); END;
getSourceLocation( ) RETURN VARCHAR2;
Returns a string containing the value of the external data source location.
None.
This method returns a VARCHAR2 string containing the value of the external data location, for example "BFILEDIR".
PRAGMA RESTRICT_REFERENCES(getSourceLocation, WNDS,
WNPS, RNDS, RNPS)
ORDSourceExceptions.INCOMPLETE_SOURCE_LOCATION
This exception is raised if you call the getSourceLocation method and the value of srcLocation is NULL.
Get the source location information about an image data source:
DECLARE Image ORDSYS.ORDImage; SourceLocation VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source location SourceLocation := Image.getSourceLocation(); END;
getSourceName( ) RETURN VARCHAR2;
Returns a string containing of the name of the external data source.
None.
This method returns a VARCHAR2 string containing the name of the external data source, for example "testimg.dat".
PRAGMA RESTRICT_REFERENCES(getSourceName, WNDS,
WNPS, RNDS, RNPS)
ORDSourceExceptions.INCOMPLETE_SOURCE_NAME
This exception is raised if you call the getSourceName( ) method and the value of srcName is NULL.
Get the source name information about an image data source:
DECLARE Image ORDSYS.ORDImage; SourceName VARCHAR2(4000); BEGIN SELECT large_photo INTO Image FROM emp WHERE ename = 'John Doe'; -- get the image source name SourceName := Image.getSourceName(); END;
getSourceType( ) RETURN VARCHAR2;
Returns a string containing the type of the external data source.
None.
Returns a VARCHAR2 string containing the type of the external data source, for example "file".
PRAGMA RESTRICT_REFERENCES(getSourceType, WNDS, WNPS, RNDS, RNPS)
None.
Get the source type information about a media data source:
DECLARE obj ORDSYS.ORDDoc; 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()); DBMS_OUTPUT.put_line(obj.getSourceType()); DBMS_OUTPUT.put_line(obj.getSourceLocation()); DBMS_OUTPUT.put_line(obj.getSourceName()); UPDATE TDOC SET doc=obj WHERE N=1; COMMIT; END; /
getUpdateTime( ) RETURN DATE;
Returns the time when the object was last updated.
None.
None.
PRAGMA RESTRICT_REFERENCES(getUpdateTime, WNDS,
WNPS, RNDS, RNPS)
None.
Get the updated time of some audio data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N = 1 ; DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getUpdateTime(),'MM-DD-YYYY HH24:MI:SS')); END; /
isLocal( ) RETURN BOOLEAN;
Returns TRUE if the data is stored locally in a BLOB or FALSE if the data is stored externally.
None.
If the local attribute is set to 1 or NULL, this method returns TRUE, otherwise this method returns FALSE.
PRAGMA RESTRICT_REFERENCES(getLocal, WNDS, WNPS, RNDS, RNPS)
None.
Determine whether or not the audio data is local:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N = 1 ; if(obj.isLocal() = TRUE) then DBMS_OUTPUT.put_line('local is set true'); else DBMS_OUTPUT.put_line('local is set false'); end if; END; /
openSource(userArg IN RAW, ctx OUT RAW) RETURN INTEGER;
Opens a data source.
The user argument. This may be used by user-defined source plug-ins.
The source plug-in context information.
The return INTEGER is 0 (zero) for success and >0 (for example, 1) for failure. The exact number and the meaning for that number is plug-in defined. For example, for the file plug-in, 1 might mean "File not found," 2 might mean "No such directory," and so forth.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the openSource( ) method and the value for srcType is NULL and data is not local.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the openSource( ) 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 openSource( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Open an external data source:
DECLARE obj ORDSYS.ORDAudio; res INTEGER; ctx RAW(4000) :=NULL; userArg RAW(4000); BEGIN SELECT aud INTO obj FROM taud WHERE N =1 FOR UPDATE; res := obj.openSource(userArg, ctx); UPDATE taud SET aud=obj WHERE N=1 ; COMMIT; 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; /
processSourceCommand(
ctx IN OUT RAW,
cmd IN VARCHAR2,
arguments IN VARCHAR2,
result OUT RAW)
RETURN RAW;
Allows you to send any command and its arguments to the source plug-in. This method is available only for user-defined source plug-ins.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see Section 5.1 for more information.
Any command recognized by the source plug-in.
The arguments of the command.
The result of calling this method returned by the source plug-in.
Use this method to send any command and its respective arguments to the source plug-in. Commands are not interpreted; they are just taken and passed through to be processed.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the processSourceCommand( ) method and the value of srcType is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the processSourceCommand( ) 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 processSourceCommand( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Process some commands:
DECLARE obj ORDSYS.ORDVideo; res RAW(4000); result RAW(4000); command VARCHAR(4000); argList VARCHAR(4000); ctx RAW(4000) :=NULL; BEGIN select vid into obj from TVID where N =1 for UPDATE; -- assign command -- assign argList res := obj.processSourceCommand(ctx, command, argList, result); UPDATE TVID SET vid=obj WHERE N=1 ; COMMIT; EXCEPTION WHEN ORDSYS.ORDSourceExceptions.METHOD_NOT_SUPPORTED THEN DBMS_OUTPUT.put_line('Source METHOD_NOT_SUPPORTED caught'); WHEN ORDSYS.ORDSourceExceptions.SOURCE_PLUGIN_EXCEPTION THEN DBMS_OUTPUT.put_line('SOURCE PLUGIN EXCEPTION caught'); WHEN ORDSYS.ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION THEN DBMS_OUTPUT.put_line('SOURCE INCOMPLETE_SOURCE_INFORMATION EXCEPTION caught'); WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('EXCEPTION caught'); END; /
readFromSource(
ctx IN OUT RAW,
startPos IN INTEGER,
numBytes IN OUT INTEGER,
buffer OUT RAW);
Allows you to read a buffer of n bytes from a source beginning at a start position.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see Section 5.1 for more information.
The start position in the data source.
The number of bytes to be read from the data source.
The buffer into which the data will be read.
This method is not supported for HTTP sources.
To successfully read HTTP source types, the entire URL source must be requested to be read. If you want to implement a read method for an HTTP source type, you must provide your own implementation for this method in the modified source plug-in for the HTTP source type.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the readFromSource( ) method and the value of srcType is NULL and data is not local.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the readFromSource( ) method and the data is local but localData is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the readFromSource( ) 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 readFromSource( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Read a buffer from the source:
DECLARE obj ORDSYS.ORDAudio; buffer RAW(4000); i INTEGER; ctx RAW(4000) :=NULL; BEGIN i := 20; select aud into obj from TAUD where N =1 ; obj.readFromSource(ctx,1,i,buffer); DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); 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;
setLocal( );
Sets the local attribute to indicate that the data is stored internally in a BLOB. When local is set, methods look for corresponding data in the source.localData attribute.
None.
This method sets the local attribute to 1 meaning the data is stored locally in localData.
None.
NULL_LOCAL_DATA
This exception is raised if you call the setLocal method and the source.localData attribute value is NULL.
Set the flag to local for the data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT s INTO obj FROM TAUD WHERE N = 1 FOR UPDATE; obj.setLocal(); UPDATE TAUD SET s=obj WHERE N = 1; COMMIT; END; /
setMimeType(mime IN VARCHAR2);
Allows you to set the MIME type of the data.
The MIME type.
You can override the automatic setting of MIME information by calling this method with a specified MIME value.
Calling this method implicitly calls the setUpdateTime( ) method.
The method setProperties( ) calls this method implicitly.
For image objects, the methods setProperties( ), process( ), and processCopy( ) call this method implicitly.
None.
INVALID_MIME_TYPE
This exception is raised if you call the setMimeType( ) method and the value for mimeType is NULL.
Set the MIME type for some stored data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('writing mimetype'); DBMS_OUTPUT.PUT_LINE('----------------'); obj.setMimeType('audio/basic'); DBMS_OUTPUT.PUT_LINE(obj.getMimeType); UPDATE TAUD SET aud=obj WHERE N=1; COMMIT; END; /
setSource(
source_type IN VARCHAR2,
source_location IN VARCHAR2,
source_name IN VARCHAR2);
Sets or alters information about the external source of the data.
The source type of the external data. See the ORDSource Object Type definition in Appendix I for more information.
The source location of the external data. See the ORDSource Object Type definition in Appendix I for more information.
The source name of the external data. See the ORDSource Object Type definition in Appendix I for more information.
Users can use this method to set the data source to a new BFILE or URL.
You must ensure that the directory exists or is created before you use this method.
Calling this method implicitly calls the setUpdateTime( ) method and the clearLocal( ) method.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the setSource( ) method and the value of srcType is NULL.
Set the source of the data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N=1 FOR UPDATE; DBMS_OUTPUT.PUT_LINE('setting and getting source'); DBMS_OUTPUT.PUT_LINE('--------------------------'); obj.setSource('file','AUDIODIR','audio.au'); DBMS_OUTPUT.PUT_LINE(obj.getSource()); UPDATE TAUD SET aud=obj WHERE N=1; COMMIT; END; /
setUpdateTime(current_time DATE);
Sets the time when the data was last updated. Use this method whenever you modify the data. Methods that modify the object attributes and all set media access methods call this method implicitly. For example, the methods setMimeType( ), setSource( ), and deleteContent( ) call setUpdateTime( ) explicitly.
The timestamp to be stored. Defaults to SYSDATE.
You must invoke this method whenever you modify the data without using object methods.
None.
None.
Set the updated time of some data:
DECLARE obj ORDSYS.ORDAudio; BEGIN SELECT aud INTO obj FROM TAUD WHERE N = 1; obj.setUpdateTime(SYSDATE); UPDATE TAUD SET aud=obj WHERE N = 1; COMMIT; END;
trim(ctx IN OUT RAW,
newlen IN INTEGER) RETURN INTEGER;
Trims a data source.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see Section 5.1 for more information.
The trimmed new length.
The return INTEGER is 0 (zero) for success and >0 (for example, 1) for failure. The exact number and the meaning for that number is plug-in defined. For example, for the file plug-in, 1 might mean "File not found," 2 might mean "No such directory," and so forth.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the trimSource( ) method and the value for srcType is NULL and data is not local.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the trimSource( ) 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 trimSource( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Trim an external data source:
DECLARE obj ORDSYS.ORDAudio; res INTEGER; ctx RAW(4000) :=NULL; BEGIN select aud into obj from TAUD where N =1 for UPDATE; res := obj.trimSource(ctx,0); UPDATE TAUD SET aud=obj WHERE N=1 ; COMMIT; 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; /
writeToSource(
ctx IN OUT RAW,
startPos IN INTEGER,
numBytes IN OUT INTEGER,
buffer IN RAW);
Allows you to write a buffer of n bytes to a source beginning at a start position.
The source plug-in context information. This must be allocated. You must call the openSource( ) method; see Section 5.1 for more information.
The start position in the source to where the buffer should be copied.
The number of bytes to be written to the source.
The buffer of data to be written.
This method assumes that the source allows you to write n number of bytes starting at a random byte location. The file and HTTP source types will not permit you to write, and do not support this method. This method will work if data is stored in a local BLOB or is accessible through a user-defined source plug-in.
None.
ORDSourceExceptions.INCOMPLETE_SOURCE_INFORMATION
This exception is raised if you call the writeToSource( ) method and the value of srcType is NULL and data is not local.
ORDSourceExceptions.NULL_SOURCE
This exception is raised if you call the writeToSource( ) method and the data is local but localData is NULL.
ORDSourceExceptions.METHOD_NOT_SUPPORTED
This exception is raised if you call the writeToSource( ) 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 writeToSource( ) method within a source plug-in when any other exception is raised.
See Appendix H for more information about these exceptions.
Write a buffer to the source:
DECLARE obj ORDSYS.ORDAudio; n INTEGER := 6; ctx RAW(4000) :=NULL; BEGIN select aud into obj from TAUD where N =1 for update; obj.writeToSource(ctx,1,n,UTL_RAW.CAST_TO_RAW('helloP')); DBMS_OUTPUT.PUT_LINE(TO_CHAR(obj.getContentLength(ctx))); update TAUD set aud = obj where N =1 ; COMMIT; 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; /
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|