How to insert pdf into postgresql(remote db) -
i have pdffile.
i insert pdf file , db available in same server using below function , command.
function
create or replace function bytea_import(p_path text, p_result out bytea) language plpgsql $$ declare l_oid oid; r record; begin p_result := ''; select lo_import(p_path) l_oid; r in ( select data pg_largeobject loid = l_oid order pageno ) loop p_result = p_result || r.data; end loop; perform lo_unlink(l_oid); end;$$;
command:
update jicontentresource set data = bytea_import('/root/desktop/avinash/avinash.pdf') id =245
when file in local server and, db available in server (remote)
if try remote server, using below command
update jicontentresource set data = bytea_import('/root/desktop/avinash/avinash.pdf') id =245
it not able take file local.
is there way achieve this?
you not able postgresql function, because function runs on database server, while file on file system on client side.
you'll have write code in client side programming language , read , import file way.
depending on api using, read file memory , use insert
or update
, or use copy ... stdin
sql command.
Comments
Post a Comment