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

Home -> Community -> Usenet -> c.d.o.misc -> Re: OWA Replacement Cartridge

Re: OWA Replacement Cartridge

From: Daniel Pinol <dpinol_at_cesca.es>
Date: 1997/07/09
Message-ID: <33C330B5.33EB44F4@cesca.es>#1/1

Dwayne A. Gaither wrote:
>
> I am trying to use the OWA replacement cartridge to upload and
> download image files from a oracle table. So far, I have been
> unsuccessful.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~4
html_page:
htp.formOpen(           'reading_procedure', 
                        'post',
                        null,
                        'multipart/form-data');
       
htp.formSubmit('operacio',llegir_client.importar_str);--msg.msg());
        htp.print('<INPUT TYPE="FILE" NAME="P_FILE" SIZE="40">');
        htp.formClose;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
reading_procedure:

   if ( owa_util.get_cgi_env('HTTP_CONTENT_TYPE') not like

                'multipart/form-data;%' )
    then
        raise_application_error( -20666,
                                'Sorry, Only Netscape 2.x/3.x can
currently upload documents' );
                return NULL;

    end if;

sv<dcd>.app

[Apps]

DBAUTH             $OWAREPLPATH$/owarepl/src/owarepl.so
owarepl_entry      0  
[AppDirs]
/bddevf            DBAUTH             /u/oracle/ows2/bin 
[DBAUTH]
owa.cfg            = /u/oracle/ows2/admin/owa.cfg
server.cfg         = /u/oracle/ows2/admin/sv<dcd>.cfg
authenticate       = another_web_agent 
web_authent_prefix = web$              
dirSeparator       = /                 

<dcd>_image_tname = NAME_OF_TABLE_WHERE_TO_INSERT_FILE_CONTENTS

owarepl/sql/image.sql

        This is an example of how to use it. The default NAME_OF_TABLE_WHERE_TO_INSERT_FILE_CONTENTS is 'image', but you can put any name as far as youi modify the sv<dcd>.app file.
create table NAME_OF_TABLE_WHERE_TO_INSERT_FILE_CONTENTS (

 NAME                                     VARCHAR2(255),
 MIME_TYPE                                VARCHAR2(30),

IMG_SIZE                                                                
NUMBER,
 IMAGE                                    LONG RAW,
 constraint image_pk primary key( name ) )
pctfree 0
/

I use the cartridge to retrieve text files. To convert the binary rows to string, you can use:

FUNCTION hex2dec2(c char) RETURN number
--Transforma un caracter que conte una xifra hexadecimal en el numero que representa
-- p.e. str='B'. Retorna 11

IS
BEGIN
        IF '0'<=c AND c<='9' THEN
                RETURN ascii(c)-ascii('0');
        ELSE
                --ABCDEF -> 10..16
                RETURN ascii(c)-ascii('A')+10;
        END IF;


END;


FUNCTION hex2dec(str varchar2) RETURN char --Transforma un string de 2 caracters al caracter que representen, segons el format
-- p.e. str='1A'. 1A es el numero 26 (16+10) => retornem el caracter amb codi 26

IS
BEGIN
        return chr(     16*hex2dec2(substr(str,1,1)) + 
                        hex2dec2(substr(str,2,1)));



END;


FUNCTION agafar_text(nom IN VARCHAR2) RETURN varchar2 --Llegeix de la taula 'f_client' (on el cartridge inserta el contingut del fitxer)
--Transformem
--si no troba fitxer--> retorna NULL
--------------------------
IS
        vc varchar2(32767):='';
        j number;

BEGIN
    --se que nomes n'hi haura un per primary key a name     --no peta per aqui mai
    FOR i IN (SELECT * FROM client_f WHERE name=nom) LOOP
        vc:='';
        --image ocupa 2*img_size (2bytes per caracter)
        for j in 0..(i.img_size-1) LOOP
                vc:=vc||hex2dec(substr(i.image,j*2+1,2));
        end loop;

    end loop;     

    DELETE FROM client_f WHERE name=nom;

    RETURN vc;



END agafar_text;

>
> It would be real helpful if someone could send sample pl/sql code that
> is being used to do this via Netscape.

         There's also an example at owarepl/sql/image.sql

Hope this helps

                Dani Pinol Received on Wed Jul 09 1997 - 00:00:00 CDT

Original text of this message

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