Re: cli in sql? - Mailing list pgsql-sql

From Greg Sabino Mullane
Subject Re: cli in sql?
Date
Msg-id 1bb9fe33ef04362819dae06d5326b2ac@biglumber.com
Whole thread Raw
In response to cli in sql?  (Frank Bax <fbax@sympatico.ca>)
Responses Re: cli in sql?  (Frank Bax <fbax@sympatico.ca>)
List pgsql-sql
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


> If my database has column containing a filename, can I use sql to present
> this filename and datemodified (as output from 'ls -l' or from mtime()
> fuction) or *must* it be done after the query in interface such as php or perl?

Neither. You can do it inside the db with a "pl" language such as plperlu:

CREATE OR REPLACE FUNCTION filemodtime(TEXT) RETURNS TEXT LANGUAGE plperlu AS
$$
my $filename = shift;
-e $filename or elog(ERROR, qq{The file "$filename" does not exist\n});
return localtime($^T - (60*60*24* -M _));
$$;

SELECT filemodtime('/var/log/messages');
SELECT filemodtime('/dark/matter');

--
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200511111457
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFDdPkRvJuQZxSWSsgRAufUAJ9f4/IaYrJDMi3Yg74x0tkN4tmUcQCgmlu9
wAkqRHgYQY9DtdIIfH/g7xY=
=n/J7
-----END PGP SIGNATURE-----




pgsql-sql by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: cli in sql?
Next
From: Frank Bax
Date:
Subject: Re: cli in sql?