From: | Herbert Liechti <Herbert(dot)Liechti(at)thinx(dot)ch> |
---|---|
To: | PostgreSQL General List <pgsql-general(at)hub(dot)org> |
Subject: | updating blobs in Perl with DBD::Pg |
Date: | 2000-10-19 07:28:06 |
Message-ID: | 39EEA286.16994C84@thinx.ch |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
I'm trying to update blob fields with the $dbh->func interface
of the Postgres driver. These functions are encapsulating the
appropriate functions of the lipq library. I'm able to create a
new blob field. Content is written correctly.
When I try to update an existing blob (overwriting the whole
content of the blob) the content is mixed up with the previous
version of the blob field. Here ist a snipped of my code:
my $lobjId = $self->getOid($_); # Returns the oid
die "Sorry got no oid for updating" unless ( $lobjId );
my $lobj_fd = $dbh->func($lobjId, $dbh->{pg_INV_WRITE}, 'lo_open');
my $len = length($self->{data}->{$field}); # new content
my $pos = $dbh->func($lobj_fd, 0, 0, 'lo_lseek'); # Seek Position 0
die "Error while positioning to 0 in oid $lobjId" unless ( defined( $pos ) );
my $nbytes = $dbh->func($lobj_fd, $self->{data}->{$_}, $len, 'lo_write');
die "Error on writing to oid" unless ( defined( $nbytes ) );
print "WROTE $nbytes of $len\n"; # Debug
die "Error while closing oid $!" unless ( $dbh->func($lobj_fd, 'lo_close'));
Does anybody know what is wrong here?
Thanks for helping
Best regards
Herbie
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Herbert Liechti E-Mail: Herbert(dot)Liechti(at)thinx(dot)ch
ThinX networked business services Stahlrain 10, CH-5200 Brugg
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From | Date | Subject | |
---|---|---|---|
Next Message | Joerg Hessdoerfer | 2000-10-19 09:00:48 | Weird effects using BLOBs from libpq |
Previous Message | Karel Zak | 2000-10-19 06:32:37 | Re: to_char function |