From: David Harel <hareldvd@gmail.com>
To: postgres sql <pgsql-sql@postgresql.org>
Subject: plperlu user function.
Date: Wed, 19 May 2010 00:29:40 +0300
Message-ID: <4BF306C4.8050101@gmail.com> (raw)
Greetings,
I am trying to write a user function on the server to retrive image
files. Currently I wrote the following:
CREATE OR REPLACE FUNCTION perl_getfile(text)
RETURNS OID AS
$BODY$
my $tmpfile = shift;
open my $IFHAND, '<', $tmpfile
or elog(ERROR, qq{could not open the file "$tmpfile": $!});
binmode $IFHAND;
my $result = '';
while(my $buffer = <$IFHAND>)
{
$result .= $buffer;
}
return $result;
$BODY$
LANGUAGE 'plperlu';
on the client I do (PHP sniplet):
$result = pg_query($dbcnx, "SELECT
perl_getfile('/home/harel/Misc/At_work.jpg')");
and I get an error:
Warning: pg_query() [function.pg-query
<http://localhost/mysqlImage1/function.pg-query;]: Query failed: ERROR:
invalid input syntax for type oid: "ÿØÿà" in
/home/harel/Prj/php/testImages/mysqlImage1/image.php
Any recommendation how to do it right?
--
Regards.
David Harel,
==================================
Home office +972 77 7657645
Cellular: +972 54 4534502
Snail Mail: Amuka
D.N Merom Hagalil
13802
Israel
Email: hareldvd@ergolight-sw.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: hareldvd@gmail.com
Subject: Re: plperlu user function.
In-Reply-To: <4BF306C4.8050101@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox