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:      harel...@ergolight-sw.com


Reply via email to