4 Oracle Multimedia Code Wizard Sample Application for the PL/SQL Gateway
The Oracle Multimedia Code Wizard sample application for the PL/SQL Gateway creates PL/SQL procedures for the PL/SQL Gateway to upload and retrieve multimedia data stored in a database using Oracle Multimedia object types.
This application assumes the following:
-
You are familiar with developing PL/SQL applications using the PL/SQL Gateway.
-
You have installed and configured the Oracle Multimedia Code Wizard sample application.
You can install the Oracle Multimedia Code Wizard sample application from the Oracle Database Examples media, which is available for download from the Oracle Technology Network (OTN). After installing the Oracle Database Examples media, the sample application files and README.txt
file are located at:
<ORACLE_HOME>
/ord/http/demo/plsgwycw
(on Linux and UNIX)
<ORACLE_HOME>
\ord\http\demo\plsgwycw
(on Windows)
This chapter describes how to run the Code Wizard sample application. See the README.txt
file for additional requirements and instructions on installing and configuring this sample application.
This chapter includes these sections:
See Also:
Oracle Multimedia PL/SQL Photo Album Sample Application for a Photo Album sample Web application that uses PL/SQL scripts to upload and retrieve media using Oracle Multimedia object types
4.1 Running the Code Wizard Sample Application
This topic describes how to run the Code Wizard application.
To use the Code Wizard sample application to create and test media access procedures, you must perform these steps:
- Create a new database access descriptor (DAD) or choose an existing DAD for use with the Code Wizard.
- Authorize use of the DAD using the Code Wizard's administration function.
- Create and test media upload and retrieval procedures.
4.2 Description of the Code Wizard Sample Application
You can use the Code Wizard sample application to create PL/SQL stored procedures for the PL/SQL Gateway to upload and retrieve media data (images, audio, video, and general media) stored in a database.
The Oracle Multimedia Code Wizard sample application uses these Oracle Multimedia object types and their respective methods:
-
ORDImage
-
ORDAudio
-
ORDVideo
-
ORDDoc
The Code Wizard guides you through a series of self-explanatory steps to create either a media retrieval procedure or a media upload procedure. You can create and compile standalone media access procedures. Or, you can create the source of media access procedures for inclusion in a PL/SQL package. Finally, after creating media access procedures, you can customize them to meet your specific application requirements.
These processes are similar to how the Oracle Multimedia PL/SQL Web Toolkit Photo Album application uses the insert_new_photo
procedure as the image upload procedure, and the deliver_media
procedure as the image retrieval procedure.
The following subsections describe how to use the Code Wizard application:
Related Topics
4.2.1 Creating a New DAD or Choosing an Existing DAD
To create media upload or retrieval procedures, you must select one or more database access descriptors (DADs) for use with the Code Wizard. To prevent the unauthorized browsing of schema tables and to prevent the unauthorized creation of media access procedures, you must authorize each DAD using the Code Wizard administration function.
Depending on your database and application security requirements, you can create and authorize one or more new DADs specifically for use with the Code Wizard. Or, you can authorize the use of one or more existing DADs.
Oracle recommends that any DAD authorized for use with the Code Wizard employ some form of user authentication mechanism. The simplest approach is to create or use a DAD that uses database authentication. To use this approach, select Basic Authentication Mode and omit the password in the DAD specification. Alternatively, you can use a DAD that specifies an existing application-specific authentication mechanism.
The following example describes how to create a DAD that enables you to create and test media upload and retrieval procedures in the SCOTT
schema.
Note:
To test media upload procedures, you must specify the name of a document table in the DAD. When testing an upload procedure, you can choose either the DAD you used to create the procedure or the DAD you used to access the application. You can choose a document table name when you create a DAD, edit a DAD to specify the document table name at a later time, or use an existing DAD that specifies a document table name. This example shows how to specify the document table name when you create the DAD.
- Set your Web browser to the Oracle HTTP Server Home page. Select PL/SQL Properties in the Administration page to open the mod_plsql Services page.
- Scroll to the DAD Status section on the mod_plsql Services page. Then, click Create to open the DAD Type page.
- Select the DAD type to be General. Then, click Next to open the Database Connection page.
- Enter
/scottcw
in the DAD Name field. EnterSCOTT
for the database account, and leave the password blank. Enter the connection information in the Database Connectivity Information section. EnterORDCWPKG.MENU
in the Default page field, and leave the other fields blank. Then, click Next to open the Document, Alias, and Session page. - Enter
MEDIA_UPLOAD_TABLE
for the Document Table on the Document, Alias, and Session page. Then, click Apply. - Restart Oracle HTTP Server for the changes to take effect.
See Also:
Oracle Database Development Guide for more information about configuring DADs
4.2.2 Authorizing a DAD
To use the Code Wizard, you must first authorize a database access descriptor (DAD).
To authorize a DAD for use with the Code Wizard, perform these steps:
See Also:
Oracle Database Development Guide for more information about configuring DADs
4.2.3 Creating and Testing Media Upload and Retrieval Procedures
After you specify and authorize a database access descriptor (DAD), you are ready to run this application to create media upload and retrieval procedures.
To start the Code Wizard after completing all the setup tasks, follow these steps:
To create a media upload procedure or a media retrieval procedure, select the appropriate option from the Main menu page, then click Next. The Code Wizard then guides you through a series of self-explanatory steps to create the procedure.
If you create a standalone media upload or retrieval procedure, you will have the opportunity to view the contents of the procedure and test it.
Related Topics
See Also:
Oracle Database Development Guide for more information about using the embedded PL/SQL Gateway
4.2.4 Creating a Media Upload Procedure
Follow this process to create a media upload procedure using the Oracle Multimedia Code Wizard for the PL/SQL Gateway.
Related Topics
4.2.5 Creating a Media Retrieval Procedure
Follow this process to create a media retrieval procedure using the Oracle Multimedia Code Wizard for the PL/SQL Gateway.
Related Topics
4.2.6 Using the PL/SQL Gateway Document Table
All files uploaded using the PL/SQL Gateway are stored in a document table. Media upload procedures created by the Code Wizard automatically move uploaded media from the specified document table to the application's table. To avoid transient files from appearing temporarily in a document table used by another application component, use a document table that is not being used to store documents permanently.
Specify the selected document table in the application's database access descriptor (DAD). If the DAD specifies a different document table, create a new DAD for media upload procedures. If you choose to create a new document table, the Code Wizard creates a table with the following format:
CREATE TABLE document-table-name ( name VARCHAR2(256) UNIQUE NOT NULL, mime_type VARCHAR2(128), doc_size NUMBER, dad_charset VARCHAR2(128), last_updated DATE, content_type VARCHAR2(128), blob_content BLOB ) -- -- store BLOBs as SecureFiles LOBs -- LOB(blob_content) STORE AS SECUREFILE;
See Also:
Oracle Database Development Guide for more information about file upload and document tables
4.2.7 How Time Zone Information Is Used to Support Browser Caching
User response times are improved and network traffic is reduced if a browser can cache resources received from a Web server and subsequently use those cached resources to satisfy future requests. This section describes, at a very high level, how the browser caching mechanism works and how the Code Wizard utility package is used to support that mechanism. Within this discussion, all HTTP date and time stamps are expressed in Coordinated Universal Time (UTC).
All HTTP responses include a Date header, which indicates the date and time when the response was generated. When a Web server sends a resource in response to a request from a browser, it can also include the Last-Modified HTTP response header, which indicates the date and time when the requested resource was last modified. The Last-Modified header must not be later than the Date header.
After receiving and caching a resource, if a browser must retrieve the same resource again, it sends a request to the Web server with the If-Modified-Since request header specified as the value of the Last-Modified date, which was returned by the application server when the resource was previously retrieved and cached. When the Web server receives the request, it compares the date in the If-Modified-Since request header with the last update time of the resource. Assuming the resource still exists, if the resource has not changed since it was cached by the browser, the Web server responds with an HTTP 304 Not Modified
status with no response body, which indicates that the browser can use the resource currently stored in its cache. Assuming again that the resource still exists, if the request does not include an If-Modified-Since header or if the resource has been updated since it was cached by the browser, the Web server responds with an HTTP 200 OK
status and sends the resource to the browser.
The ORDImage, ORDAudio, ORDVideo, and ORDDoc objects all possess an updateTime attribute stored as a DATE in the embedded ORDSource object. Although the DATE data type has no support for time zones or daylight savings time, Oracle Database does support time zones and also provides functions for converting a DATE value stored in a database to UTC.
When a response is first returned to a browser, a media retrieval procedure sets the Last-Modified HTTP response header based on the updateTime attribute. If a request for media data includes an If-Modified-Since header, the media retrieval procedure compares the value with the updateTime attribute and returns an appropriate response. If the resource in the browser's cache is still valid, an HTTP 304 Not Modified
status is returned with no response body. If the resource has been updated since it was cached by the browser, then an HTTP 200 OK
status is returned with the media resource as the response body. Media retrieval procedures created by the Code Wizard call the utility package to convert a DATE value stored in the database to UTC. The utility package uses the time zone information stored with Oracle Database and the date and time functions to convert database date and time stamps to UTC. To ensure that the resulting date conforms to the rule for the Last-Modified date described previously, the time zone information must be specified correctly.
See Also:
-
W3C HTTP- Hypertext Transfer Protocol for more information about the HTTP specification
-
Oracle Database Administrator's Guide for more information about how to set a time zone for a database
-
Oracle Database SQL Language Reference for more information about date and time functions
4.3 Sample Session: Using Images
This sample session uses the SCOTT
schema to demonstrate the creation of image media upload and retrieval procedures. To use a different schema, substitute a different schema name and password. Or, if you have changed the password for the SCOTT
schema, use your new password.
Perform these steps:
- Step 1. Create a table to store images for the application after connecting to a schema with privileges to create a table.
-
For example:
SQL> CREATE TABLE cw_images_table( id NUMBER PRIMARY KEY, description VARCHAR2(30) NOT NULL, location VARCHAR2(30), image ORDSYS.ORDIMAGE ) -- -- store media as SecureFiles LOBs -- LOB(image.source.localdata) STORE AS SECUREFILE;
-
Step 2. Create the
SCOTTCW
DAD to be used to create the procedures. -
-
Set your Web browser to the Oracle HTTP Server Home page. Select PL/SQL Properties in the Administration page to open the mod_plsql Services page.
-
On the mod_plsql Services page, scroll to the DAD Status section. Then, click Create to open the DAD Type page.
-
Select the DAD type to be General. Then, click Next to open the Database Connection page.
-
Enter
/scottcw
in the DAD Name field. EnterSCOTT
for the database account, and leave the password blank. Enter the connection information in the Database Connectivity Information section. EnterORDCWPKG.MENU
in the Default page field, and leave the other fields blank. Then, click Next to open the Document, Alias, and Session page. -
On the Document, Alias, and Session page, enter
MEDIA_UPLOAD_TABLE
for the Document Table. Then, click Apply. -
Restart Oracle HTTP Server for the changes to take effect.
-
-
Step 3. Authorize the use of the
SCOTTCW
DAD andSCOTT
schema with the Code Wizard. -
-
Enter the Code Wizard's administration URL into your browser's location bar, then enter the
ORDSYS
user name and password when prompted by the browser, for example:http://
<hostname>
:<port-number>
/ordcwadmin -
Select the DAD authorization function from the Code Wizard's Main menu and click Next. Enter the name of the demonstration DAD,
SCOTTCW
, and the user nameSCOTT
, then click Apply. Click Done when the confirmation window is displayed.
-
-
Step 4. Change DADs to the
SCOTTCW
DAD. -
-
Click Change DAD from the Code Wizard's Main menu.
-
Click Change to SCOTTCW, if it is not already selected, then click Next.
-
Enter the user name
SCOTT
and the password for the user SCOTT when prompted for the user name and password, then click OK.The Main menu now displays the current DAD as
SCOTTCW
and the current schema asSCOTT
.
-
- Step 5. Create and test the media upload procedure.
-
Click Create media upload procedure from the Main menu, then click Next.
-
Select the database table and procedure type.
-
Click the CW_IMAGES_TABLE database table.
-
Click Standalone procedure.
-
Click Next.
-
-
Select the PL/SQL document upload table.
If there are no document tables in the
SCOTT
schema, the Code Wizard displays a message indicating this situation. In this case, accept the default table name provided,CW_SAMPLE_UPLOAD_TABLE
, then click Next.If there are existing document tables, but the
CW_SAMPLE_UPLOAD_TABLE
is not among them, click Create new document table, accept the default table name provided,CW_SAMPLE_UPLOAD_TABLE
, then click Next.If the
CW_SAMPLE_UPLOAD_TABLE
document table already exists, ensure that the Use existing document table and the CW_SAMPLE_UPLOAD_TABLE options are selected. Click Next. -
Select the data access and media columns.
-
Click IMAGE (ORDIMAGE).
-
Click ID (Primary key).
-
Click Conditional insert or update.
-
Click Next.
-
-
Select additional columns and procedure names.
-
Ensure that DESCRIPTION checkmarked because this column has a
NOT NULL
constraint. (The LOCATION column is not checkmarked by default as there are no constraints on this column.) -
Accept the procedure name provided,
UPLOAD_CW_IMAGES_TABLE_IMAGE
. -
Click Create procedure in the database.
-
Click Next.
-
-
Review the following selected procedure creation options that are displayed:
Procedure type: Standalone Table name: CW_IMAGES_TABLE Media column(s): IMAGE (ORDIMAGE) Key column: ID Additional column(s): DESCRIPTION Table access mode: Conditional update or insert Procedure name: UPLOAD_CW_IMAGES_TABLE_IMAGE Function: Create procedure in the database
Click Finish.
-
Compile the procedure and review the generated source information.
The Code Wizard displays this message:
Procedure created successfully: UPLOAD_CW_IMAGES_TABLE_IMAGE
-
At the option Click to display generated source:, click View to view the generated source in another window. A copy of the generated source is shown at the end of Step 5, substep 6g.
-
Close the window after looking at the generated source.
-
Accept the DAD: name provided,
SCOTTCW
, then click Test to produce another window that displays a template file upload form that you can use to test the generated procedure. -
To customize the template file upload form, select Save As... from your browser's File menu to save the HTML source for editing.
-
To test the template upload form, enter this information:
-
For the ID: column, enter the number
1
as the row's primary key. -
For the IMAGE column, click Browse... and choose an image file to upload to the database.
-
For the DESCRIPTION column, enter a brief description of the image.
-
Click Upload media.
The Code Wizard displays a template completion window with the heading Oracle Multimedia Code Wizard: Template Upload Procedure, and, if the procedure is successful, the message:
Media uploaded successfully
. -
-
Close the window.
-
Click Done on the Compile procedure and review generated source window to return to the Main menu of the Code Wizard.
A copy of the generated image upload procedure follows:
CREATE OR REPLACE PROCEDURE UPLOAD_CW_IMAGES_TABLE_IMAGE ( in_ID IN VARCHAR2, in_IMAGE IN VARCHAR2 DEFAULT NULL, in_DESCRIPTION IN VARCHAR2 DEFAULT NULL ) AS local_IMAGE ORDSYS.ORDIMAGE := ORDSYS.ORDIMAGE.init(); local_ID CW_IMAGES_TABLE.ID%TYPE := NULL; upload_size INTEGER; upload_mimetype VARCHAR2( 128 ); upload_blob BLOB; BEGIN -- -- Update the existing row. -- UPDATE CW_IMAGES_TABLE mtbl SET mtbl.IMAGE = local_IMAGE, mtbl.DESCRIPTION = in_DESCRIPTION WHERE mtbl.ID = in_ID RETURN mtbl.ID INTO local_ID; -- -- Conditionally insert a new row if no existing row is updated. -- IF local_ID IS NULL THEN -- -- Insert the new row into the table. -- INSERT INTO CW_IMAGES_TABLE ( ID, IMAGE, DESCRIPTION ) VALUES ( in_ID, local_IMAGE, in_DESCRIPTION ); END IF; -- -- Select Oracle Multimedia object(s) for update. -- SELECT mtbl.IMAGE INTO local_IMAGE FROM CW_IMAGES_TABLE mtbl WHERE mtbl.ID = in_ID FOR UPDATE; -- -- Store media data for the column in_IMAGE. -- IF in_IMAGE IS NOT NULL THEN SELECT dtbl.doc_size, dtbl.mime_type, dtbl.blob_content INTO upload_size, upload_mimetype, upload_blob FROM CW_IMAGE_UPLOAD_TABLE dtbl WHERE dtbl.name = in_IMAGE; IF upload_size > 0 THEN dbms_lob.copy( local_IMAGE.source.localData, upload_blob, upload_size ); local_IMAGE.setLocal(); BEGIN local_IMAGE.setProperties(); EXCEPTION WHEN OTHERS THEN local_IMAGE.contentLength := upload_size; local_IMAGE.mimeType := upload_mimetype; END; END IF; DELETE FROM CW_IMAGE_UPLOAD_TABLE dtbl WHERE dtbl.name = in_IMAGE; END IF; -- -- Update Oracle Multimedia objects in the table. -- UPDATE CW_IMAGES_TABLE mtbl SET mtbl.IMAGE = local_IMAGE WHERE mtbl.ID = in_ID; -- -- Display the template completion message. -- htp.print( '<html>' ); htp.print( '<title>Oracle Multimedia Code Wizard: Template Upload Procedure</title>' ); htp.print( '<body>' ); htp.print( '<h2> Oracle Multimedia Code Wizard: Template Upload Procedure</h2>' ); htp.print( 'Media uploaded successfully.' ); htp.print( '</body>' ); htp.print( '</html>' ); END UPLOAD_CW_IMAGES_TABLE_IMAGE;
The previous image upload procedure declares these input parameters and variables:
-
In the declaration section, the procedure declares three input parameters:
in_ID
,in_IMAGE
, andin_DESCRIPTION
, then initializes the latter two toNULL
. -
In the subprogram section, the following variables are declared:
-
The variable
local_IMAGE
is assigned the data type ORDSYS.ORDIMAGE and initialized with an empty BLOB using the ORDIMAGE.init( ) method. -
The variable
local_ID
takes the same data type as theID
column in the tableCW_IMAGES_TABLE
and is initialized toNULL
. -
Three additional variables are declared
upload_size
,upload_mimetype
, andupload_blob
, which are later given values from comparable column namesdoc_size
,mime_type
, andblob_content
from the document tableCW_IMAGE_UPLOAD_TABLE
, using a SELECT statement in preparation for copying the content of the image BLOB data to the ORDSYS.ORDIMAGE.source.localData attribute.
-
Within the outer BEGIN...END executable statement section, the following operations are executed:
-
Update the existing row in the table
CW_IMAGES_TABLE
for theIMAGE
andDESCRIPTION
columns and return the value oflocal_ID
where the value of theID
column is the value of thein_ID
input parameter. -
If the value returned of
local_ID
isNULL
, conditionally insert a new row into the tableCW_IMAGES_TABLE
and initialize the instance of the ORDImage object type in theimage
column with an empty BLOB. -
Select the ORDImage object column
IMAGE
in the tableCW_IMAGES_TABLE
for update where the value of theID
column is the value of thein_ID
input parameter. -
Select a row for the
doc_size
,mime_type
, andblob_content
columns from the document table and pass the values to theupload_size
,upload_mimetype
, andupload_blob
variables where the value of the document tableName
column is the value of thein_IMAGE
input parameter. -
Perform a DBMS_LOB copy of the BLOB data from the table
CW_IMAGE_UPLOAD_TABLE
into the ORDSYS.ORDIMAGE.source.localData attribute, then call the setLocal( ) method to indicate that the image data is stored locally in the BLOB, and ORDImage methods are to look for corresponding data in the source.localData attribute. -
In the inner executable block, call the ORDImage setProperties( ) method to read the image data to get the values of the object attributes and store them in the image object attributes for the ORDImage object.
-
If the setProperties( ) call fails, catch the exception and call the contentLength( ) method to get the size of the image and call the mimeType( ) method to get the MIME type of the image.
-
Delete the row of data from the document table
CW_IMAGE_UPLOAD_TABLE
that was copied to the row in the tableCW_IMAGES_TABLE
where the value of theName
column is the value of thein_IMAGE
input parameter. -
Update the ORDImage object
IMAGE
column in the tableCW_IMAGES_TABLE
with the content of the variablelocal_IMAGE
where the value of theID
column is the value of thein_ID
input parameter. -
Display a completion message on the HTML page to indicate that the media uploaded successfully using the
htp.print
function from the PL/SQL Web Toolkit.
-
-
- Step 6. Create and test a media retrieval.
-
Select Create media retrieval procedure from the Main menu, then click Next.
-
Select the database table and procedure type.
-
Click CW_IMAGES_TABLE.
-
Click Standalone procedure.
-
Click Next.
-
-
Select the media column and key column.
-
Click IMAGE (ORDIMAGE).
-
Click ID (Primary key).
-
Click Next.
-
-
Select the procedure name and parameter name.
-
Accept the procedure name provided,
GET_CW_IMAGES_TABLE_IMAGE
. -
Accept the parameter name provided,
MEDIA_ID
. -
Click Create procedure in the database.
-
Click Next.
-
-
Review the following selected procedure creation options:
Procedure type: Standalone Table name: CW_IMAGES_TABLE Media column(s): IMAGE (ORDIMAGE) Key column: ID Procedure name: GET_CW_IMAGES_TABLE_IMAGE Parameter Name: MEDIA_ID Function: Create procedure in the database
Click Next.
-
Compile the procedure and review the generated source.
The Code Wizard displays this message:
Procedure created successfully: GET_CW_IMAGES_TABLE_IMAGE
-
Click View to view the generated source in another window. Close the window after looking at the generated source. A copy of the generated source is shown at the end of Step 6, substep 5e.
-
Review the URL format used to retrieve images using the
GET_CW_IMAGES_TABLE_IMAGE
procedure. -
Enter the number
1
as the Key parameter, then click Test to test the procedure by retrieving the image uploaded previously.The retrieved image is displayed in another window.
-
Close the window.
-
Click Done to return to the Main menu.
A copy of the generated image retrieval procedure follows:
CREATE OR REPLACE PROCEDURE GET_CW_IMAGES_TABLE_IMAGE ( MEDIA_ID IN VARCHAR2 ) AS localObject ORDSYS.ORDIMAGE; localBlob BLOB; localBfile BFILE; httpStatus NUMBER; lastModDate VARCHAR2(256); BEGIN -- -- Retrieve the object from the database into a local object. -- BEGIN SELECT mtbl.IMAGE INTO localObject FROM CW_IMAGES_TABLE mtbl WHERE mtbl.ID = MEDIA_ID; EXCEPTION WHEN NO_DATA_FOUND THEN ordplsgwyutil.resource_not_found( 'MEDIA_ID', MEDIA_ID ); RETURN; END; -- -- Check the update time if the browser sent an If-Modified-Since header. -- IF ordplsgwyutil.cache_is_valid( localObject.getUpdateTime() ) THEN owa_util.status_line( ordplsgwyutil.http_status_not_modified ); RETURN; END IF; -- -- Figure out where the image is. -- IF localObject.isLocal() THEN -- -- Data is stored locally in the localData BLOB attribute. -- localBlob := localObject.getContent(); owa_util.mime_header( localObject.getMimeType(), FALSE ); ordplsgwyutil.set_last_modified( localObject.getUpdateTime() ); owa_util.http_header_close(); IF owa_util.get_cgi_env( 'REQUEST_METHOD' ) <> 'HEAD' THEN wpg_docload.download_file( localBlob ); END IF; ELSIF UPPER( localObject.getSourceType() ) = 'FILE' THEN -- -- Data is stored as a file from which ORDSource creates -- a BFILE. -- localBfile := localObject.getBFILE(); owa_util.mime_header( localObject.getMimeType(), FALSE ); ordplsgwyutil.set_last_modified( localObject.getUpdateTime() ); owa_util.http_header_close(); IF owa_util.get_cgi_env( 'REQUEST_METHOD' ) <> 'HEAD' THEN wpg_docload.download_file( localBfile ); END IF; ELSIF UPPER( localObject.getSourceType() ) = 'HTTP' THEN -- -- The image is referenced as an HTTP entity, so we have to -- redirect the client to the URL that ORDSource provides. -- owa_util.redirect_url( localObject.getSource() ); ELSE -- -- The image is stored in an application-specific data -- source type for which no default action is available. -- NULL; END IF; END GET_CW_IMAGES_TABLE_IMAGE;
The image retrieval procedure shown previously declares these input parameters and variables:
-
In the declaration section, the procedure declares one input parameter:
MEDIA_ID
. -
In the subprogram section, the following variables are declared:
-
The variable
localObject
is assigned the data type ORDSYS.ORDIMAGE. -
The variable
localBlob
is a BLOB data type, the variablelocalBfile
is a BFILE data type,httpStatus
is a NUMBER, andlastModDate
is a VARCHAR2 with a maximum size of 256 characters.
-
Within the outer BEGIN...END executable statement section, the following operations are executed:
-
Select the ORDImage object column
IMAGE
in the tableCW_IMAGES_TABLE
where the value of theID
column is the value of theMEDIA_ID
input parameter. -
In the inner executable block, when no data is found, raise an exception and call the
resource_not_found
function of the PL/SQL Gateway and get the value of theMEDIA_ID
input parameter. -
Check the update time if the browser sent an If-Modified-Since header by calling the getUpdateTime( ) method passed into the
cache_is_valid
function of the PL/SQL Gateway. -
If the cache is valid, send an HTTP status code to the client using the PL/SQL Web Toolkit
owa_util
packagestatus_line
procedure passing in the call to thehttp_status_not_modified
function. -
Determine where the image data is stored; call the ORDImage isLocal( ) method, which returns a Boolean expression of true if the image data is stored locally in the BLOB, then get the handle to the local BLOB.
-
If the value is true, assign the variable
localBlob
the ORDImage getContent( ) method to get the handle of the local BLOB containing the image data. -
Call the ORDImage getMimeType( ) method to determine the image's MIME type and pass this to the
owa_util.mime_header
procedure and keep the HTTP header open. -
Call the ORDImage getUpdateTime( ) method to get the time the image was last modified and pass this to the
ordplsgwyutil.set_last_modified
procedure. -
Close the HTTP header by calling the
owa_util.http_header_close( )
procedure. -
Call the
owa_util.get_cgi_env
procedure and if the value of the request method is notHEAD
, then use thewpg_docload.download_file
procedure to pass in the value oflocalBlob
that contains the LOB locator of the BLOB containing the image data to download the image from the database.
-
-
If the ORDImage isLocal( ) method returns false, call the ORDImage getSourceType( ) method to determine if the value is
FILE
; if so, then the image data is stored as an external file on the local file system. Then, get the LOB locator of the BFILE containing the image data.-
Assign the variable
localBfile
the ORDImage getBfile( ) method to get the LOB locator of the BFILE containing the image data. -
Call the ORDImage getMimeType( ) method to determine the image's MIME type and pass this to the
owa_util.mime_header
procedure and keep the HTTP header open. -
Call the ORDImage getUpdateTime( ) method to get the time the image was last modified and pass this to the
ordplsgwyutil.set_last_modified
procedure. -
Close the HTTP header by calling the
owa_util.http_header_close()
procedure. -
Call the
owa_util.get_cgi_env
procedure and if the value of the request method is notHEAD
, then use thewpg_docload.download_file
procedure to pass in the value oflocalBfile
that contains the LOB locator of the BFILE containing the image data to download the image from the file.
-
-
If the ORDImage isLocal( ) method returns false, call the ORDImage getSourceType( ) method to determine if the value is
HTTP
; if so, then the image data is stored at an HTTP URL location, which then redirects the client to the URL that ORDSource provides using theowa_util.redirect_url
procedure. -
If the ORDImage isLocal( ) method returns false, call the ORDImage getSourceType( ) method to determine if the value is
FILE
orHTTP
; if it is neither, then the image is stored in an application-specific data source type that is not recognized or supported by Oracle Multimedia.
-
-
See Also:
Oracle Database Security Guide for more information about creating secure passwords
4.4 Known Restrictions of the Oracle Multimedia Code Wizard
The Code Wizard supports the features of Oracle Multimedia, with a few known restrictions.
The following restrictions are known for the Oracle Multimedia Code Wizard:
-
Tables with composite primary keys are not supported.
To use a table with a composite primary key, create an upload or download procedure, then edit the generated source to support all the primary key columns. For example, for a media retrieval procedure, this might involve adding an additional parameter, then specifying that parameter in the
where
clause of the SELECT statement. -
User object types containing embedded Oracle Multimedia object types are not recognized by the Oracle Multimedia Code Wizard.