#---------------------------------------------------------
#
# $Id: README,v 1.1 1997/09/15 19:14:07 mergl Exp $
#
#---------------------------------------------------------

Although the DBI documentation has blobs on its list of outstanding issues, 
there is a blob_read method, which is now also supported by the DBD-Pg module. 

The given template for the blob_read method 

  $sth->blob_read(field, offset, len, destrv, destoffset) 

seems to be heavily influenced by the current implementation of blobs in 
Oracle. Nevertheless the DBD-Pg module tries to be as compatible as possible. 

Whereas Oracle suffers from the limitation that blobs are related to tables 
and every table can have only one blob (data-type LONG), PostgreSQL handles 
its blobs independent of any table by using so called object identifiers. This 
explains why the blob_read method is blessed into the STATEMENT package and 
not part of the DATABASE package. Here the field parameter has been used to 
handle this object identifier. 

Blobs are usually fetched in chunks which should have an optimized size. This 
size is system and database dependent. The current DBD-Oracle implementation 
leaves it up to the user to handle the loop of fetching single chunks and 
defining the chunk size:

    my $blob = '';
    my $lump = 4096;
    my $offset = 0;
    while (1)
    {
        my $frag = $sth->blob_read(0, $offset, $lump);
        last unless defined $frag;
        my $ll = length $frag;
        last unless $ll;
        $blob .= $frag;
        $offset += $ll;
    }

In contrary the DBD-Pg module does this work by itself, so that the user can 
fetch a blob with a single statement:

    $blob = $sth->blob_read($lobj_id, 0, 0); 

Nevertheless existing scripts should work, just by defining the offset and len 
parameters.

Please keep in mind, that the blob_read method provided by the DBI module as 
well as its implementation in the DBD-Pg module might change. 


---------------------------------------------------------------------------

   Edmund Mergl <E.Mergl@bawue.de>                     August 22, 1997

---------------------------------------------------------------------------
