plperlu user function.

From: David Harel <hareldvd(at)gmail(dot)com>
To: postgres sql <pgsql-sql(at)postgresql(dot)org>
Subject: plperlu user function.
Date: 2010-05-18 21:29:40
Message-ID: 4BF306C4.8050101@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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(at)ergolight-sw(dot)com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Alex Hunsaker 2010-05-18 21:36:27 Re: plperlu user function.
Previous Message Kenneth Marshall 2010-05-18 19:28:55 Re: How to get CURRENT_DATE in a pl/pgSQL function