Open Source Development Tutorials | Newsletter Signup | About Us
Search  

Go Back   Open Source Tutorials Forum > Databases > PostgreSQL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-22-2007, 12:44 PM
Greg Coates Greg Coates is offline
Junior Member
 
Join Date: Jan 2007
Posts: 1 Greg Coates is on a distinguished road
Default Problem with Perl and PostgreSQL blobs

Hi. I'm working on a perl script that will insert image files as blobs into a PostgreSQL database.

I have a function that should take a blob from memory (the $blob variable), insert it into the database, and return the new Object ID. (The $bytes variable is the size of the blob in bytes.) :
sub insert_thumb_object {
my ($dbh, $bytes, $blob) = @_;

my $oid = $dbh->func($dbh->{pg_INV_WRITE}, 'lo_creat');
my $fd = $dbh->func($oid, $dbh->{pg_INV_WRITE}, 'lo_open');
my $bytes_written = $dbh->func($fd, $blob, $bytes, 'lo_write');

return $oid;
}


The problem is, it's not working. The 'lo_creat' call works fine, and I get an oid, but I'm getting a null file descriptor on the 'lo_open' call, and then of course the 'lo_write' call fails as well.

Does anyone have any idea what I might be doing wrong?

Last edited by Greg Coates : 01-22-2007 at 12:45 PM. Reason: Changing email notification
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump



All times are GMT -5. The time now is 11:11 PM.


Powered by: vBulletin Version 3.0.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright 2004 - 2006 GrindingGears.com. All Rights Reserved.