Hi,
Am Sa, den 06.11.2004 schrieb Leo Martin Orfei um 13:52:
> ok. I gonna explain a little more my situation.
>
> I have a postgres server (Linux) and clients
> (Win2k+delphi application).
> I need create a text file with some columns from a
> table in the server machine, but this file must be
> created only when the user wants. (click button on my
> delphi program on the client side create a text file
> on the server file system).
> I can't share o mount a resource or connect by socket.
> I think execute a postgres function from delphi and
> leave to postgres a work to create the file.
>
> so, my problem is how to create a text file from a
> postgres function. may be I can use a java program
> (like Oracle Java Stored Procedures).
> How I execute a external java program from postgres
> function?
> exist some OS system call in postgres?
>
> something like
> Create or Replace Function run () returns int4 as
> begin
> execute_OS_system_call('java -jar someapp.jar');
> return (1);
> end;
Well. Although there is a project for java as function
language, I dont think its the best option when you
look at startup times and memory footprint.
You can either do with temp tables and copy
or use any of the *u languages (u=unrestricted)
for example plpythonu
CREATE FUNCTION makefile(text) RETURNS text AS '
o=open("/path/to/file")
o.write(args[0])
o.close()
return "ok"
' LANGUAgE plpythonu;
Regards
Tino