24 lines
426 B
PL/PgSQL
Executable File
24 lines
426 B
PL/PgSQL
Executable File
-- # $Id$
|
|
-- # $HeadURL$
|
|
-- # $Author$
|
|
|
|
CREATE FUNCTION bytea_import(p_path text, OUT p_result bytea) RETURNS bytea
|
|
LANGUAGE plpgsql
|
|
AS $$
|
|
|
|
DECLARE
|
|
l_oid oid;
|
|
r record;
|
|
|
|
BEGIN
|
|
|
|
p_result := '';
|
|
SELECT lo_import(p_path) INTO l_oid;
|
|
for r in ( SELECT data FROM pg_largeobject WHERE loid = l_oid ORDER BY pageno ) loop
|
|
p_result = p_result || r.data;
|
|
end loop;
|
|
perform lo_unlink(l_oid);
|
|
|
|
END;$$;
|
|
|