Re: storing graphics in oracle

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 1996/11/03
Message-ID: <327bfa96.2186333_at_dcsun4>#1/1


On Fri, 25 Oct 96 10:59:22 GMT, johne_at_parallax.co.uk (John Eccleston) wrote:

>In article <326D05BB.1D85_at_intelsat.int>, Rohit Saran <rohit.saran_at_intelsat.int> wrote:
>>If one stores a bit-mapped graphics in Oracle, how does one retrieve
>>it.. Can it be done using SQL or some other techniques have to be used.
>>Any pointers will be appreciated.
>>
>>Thanks/Rohit...
>
>Hi,
>
>Be aware that PL/SQL allows a maximum 32K to be read for a LONG column.
>It gives errors when attempting to read LONG columns containing more data
>than this.
>
>Pro*C can be used to insert and select from LONG columns however I think
>it must be done as one block. It would be really nice if you could read
>the LONG column in chunks (like reading a file).
>
>Regards
>
>John
>
>________________________________________________________________
>Parallax Solutions Ltd. Tel.: 01203 514522
>Stonecourt, Fax.: 01203 514401
>Siskin Drive, Web : http://www.parallax.co.uk/~johne
>Coventry CV3 4FJ Mail: johne_at_parallax.co.uk
>________________________________________________________________
> Kaizen - Japanese, Lit: Never ending improvement
>________________________________________________________________
>
>

With any version of 7.x you can piecewise fetch using OCI (can be mixed with pro*c easily). With 7.3 you can piecewise insert and update in OCI as well. Pro*c, not being an API but declaritive, doesn't lend itself to piecewise fetching as OCI does.

With 7.3, you can piecewise fetch using pl/sql. the following example is a subroutine I use that takes an open cursor, assumes the first column is a long, fetches it 4k at a time and prints it out.

This works with raws as well...

procedure showlong( p_cursor in integer ) as

    l_cursor    integer default p_cursor;
    l_n         number;
    l_long_val  varchar2(4096);
    l_long_len  number;
    l_buflen    number := 4096;
    l_curpos    number := 0;

begin  

    dbms_sql.define_column_long(l_cursor, 1);     l_n := dbms_sql.execute(l_cursor);  

    htp.preOpen;
    if (dbms_sql.fetch_rows(l_cursor)>0)     then

        loop
            dbms_sql.column_value_long(l_cursor, 1, l_buflen, l_curpos ,
                                        l_long_val, l_long_len );
            l_curpos := l_curpos + l_buflen;
            htp.ps( l_long_val );
            exit when l_long_len = 0;
      end loop;

   end if;
   htp.preClose;
   dbms_sql.close_cursor(l_cursor);
exception

   when others then

      if dbms_sql.is_open(l_cursor) then
         dbms_sql.close_cursor(l_cursor);
      end if;
      htp.preClose;
      raise;

end showlong;  

Thomas Kyte
Oracle Government
tkyte_at_us.oracle.com                          

http://govt.us.oracle.com

  • Check out Oracle Governments web site! ----- Follow the link to "Tech Center" and then downloadable Utilities for some free software...

statements and opinions are mine and do not necessarily reflect the opinions of Oracle Corporation Received on Sun Nov 03 1996 - 00:00:00 CET

Original text of this message