Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle as HTTP server?

Re: Oracle as HTTP server?

From: ek <nirkeen_at_saber.net>
Date: Sun, 28 Oct 2001 22:36:31 -0800
Message-ID: <ttpu8m7fb2dce2@corp.supernews.com>


It's a not very hard for any version of Oracle 7+ - provided you have a working version of the PL/SQL cartridge.

Some hints from my experience:

  1. Install Oracle's web server (Apache for 8.1.7 or wlsnrctl etc... for lower versions) in a separate Oracle home. Create the link to the source database as a DAD with SQL*Net - it can be on another system.
  2. Install support only for the HTP package (see Oracle's doc on command line install of WEBDB) for details.
  3. Write a simple fetch-from-blob package and set the mime type to whatever you need.

Here's a segment sample - don't try to compile as it's roughly pasted.

http://yourserver:#port#/your_package.get_music?music_id=[primary_key]

PROCEDURE get_music (music_id number) AS

   Lob_field BLOB;
   buffer RAW(32767);
   offset BINARY_INTEGER:=1;
   buffer_size NUMBER:=32767; --- adjust to your application    nImageId NUMBER := music_id;
BEGIN
-- retrieve the LOB locator into the PL/SQL locator variable lob_field   SELECT music_image

     INTO  lob_field
     FROM music_image c

  WHERE c.music_id = nMusicId;
-- The mime header is sent first before sending the image -- content

   OWA_UTIL.MIME_HEADER('image/mp3');
-- read the LOB content in a loop and send it across to the browser

    LOOP
     DBMS_LOB.READ(lob_field,buffer_size,offset,buffer); -- convert the raw content read into varchar2 and send it to the browser

      htp.prn(UTL_RAW.CAST_TO_VARCHAR2(buffer));
      htp.prn(buffer);
      offset:=offset+buffer_size;

    END LOOP;
-- Catch the no_data_found exception.This is raised by the dbms_lob.read
-- procedure
-- when the end of the LOB is reached and there are no more bytes to read
EXCEPTION
WHEN NO_DATA_FOUND THEN
 htp.print('MUSIC record not found for primary key value: '|| TO_CHAR(nMusicId));
WHEN OTHERS THEN
 htp.print('Database Error: ' || SUBSTR(SQLERRM,1,200)); END get_music;

Eric

Joost Mulders wrote in message <3BD592AE.3F252C65_at_j-mulders.demon.nl>...
>Hi,
>
>I have an 8.1.5 database with a bunch of mp3's in BLOBS. Is there an easy
way to give access to the files via HTTP for personal use, i.e. Oracle as a webserver?
>
>I am simple and I want to be able to execute simple commands like "mpg123
"http://oracle_database_server/mp3file.mp3"
>
>Is this possible?, where to start looking ?
>
>Thanks !
>
>Joost
Received on Mon Oct 29 2001 - 00:36:31 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US