Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    4

    Unanswered: Problem with wpg_docload

    I have problem with downloading (displaying) BLOBs from database. I have one table:

    CREATE TABLE article(
    ID NUMBER(6) NOT NULL,
    NAME_ENG VARCHAR2(255) NOT NULL,
    SOURCE BLOB,
    FILE_FORMAT NUMBER(6)
    )

    where file_format is foreign key to the table 'doctypes':

    CREATE TABLE doctype(
    ID NUMBER(6) NOT NULL,
    NAME VARCHAR2(3) NOT NULL,
    MIME_TYPE VARCHAR2(128)
    );

    BEGIN
    SELECT source,doctype.mime_type mime_type INTO pSource,pMime FROM article,doctype WHERE article.id = parID AND article.file_format = doctype.id;

    /*doesn't work!!!, The page cannot be displayed (MSIE error)*/

    owa_util.mime_header('text/html',FALSE);
    HTP.P('Content-Length: '||DBMS_LOB.GETLENGTH(pSource));
    owa_util.http_header_close;
    wpg_docload.download_file(pSource);

    /*it works, but" pdf files are empty (no characters), but filesizes are correct; text,html files represents correctly*/

    LOOP
    DBMS_LOB.READ(pSource,pAmount,pOffset,pRaw);
    HTP.PRN(utl_raw.cast_to_varchar2(pRaw));
    pOffset := pOffset + pAmount;
    pAmount := 4096;
    END LOOP;

    END;

    Please help.

  2. #2
    Join Date
    Mar 2004
    Location
    Berkshire, UK
    Posts
    186
    I assume you are retrieving the docs via the Oracle apache http server?

    this is using the stndard dad config, ie /docs to retrieve the files

    PHP Code:
    CREATE OR REPLACE PROCEDURE GET_IMG
     IS
    vblob blob
    ;
        
    mime_type VARCHAR2(50);
        
    buffer RAW(32000);
        
    buffer_size INTEGER := 32000;
        
    offset INTEGER := 1;
        
    vlength NUMBER;
        
    v_filename VARCHAR2(255);

        
    script_name VARCHAR2(255) DEFAULT owa_util.get_cgi_env('SCRIPT_NAME');
        
    path_info   VARCHAR2(255) DEFAULT owa_util.get_cgi_env('PATH_INFO');
        
    pos         NUMBER;
    BEGIN
        script_name 
    := script_name || path_info;
        
    pos := INSTR(script_name'docs');
        
    script_name :=  SUBSTR(script_namepos+5LENGTH(script_name)-pos-4);

        
    SELECT /*+ index_ffs(t1 wwv_document_pk) */ name
        INTO v_filename
        FROM wwv_document
    t1
        WHERE UPPER
    (t1.name) = UPPER(script_name);

        
    SELECT blob_contentmime_type INTO vblobmime_type FROM wwv_documentWHERE name v_filename;
        
    owa_util.mime_header(mime_type);
        
    vlength := dbms_lob.getlength(vblob);
        WHILE 
    offset vlength LOOP
            dbms_lob
    .read(vblobbuffer_sizeoffsetbuffer);
            
    htp.prn(utl_raw.cast_to_varchar2(buffer));
            
    offset := offset buffer_size;
        
    END LOOP;
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
            htp
    .p('No Image');
        
    WHEN OTHERS THEN
            htp
    .p(SQLERRM);
    END
    this is called get_img but will work for any doc where wwv_document$ is the blob table
    There are 10 types of people in the world, those that know Binary and those that don't.

  3. #3
    Join Date
    May 2004
    Posts
    4
    I have BLOB (PDFs,MS Word documents, jpegs) stored in database table and want to display it in browser (with using wpg_docload procedure)...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •