From: | "Greg Sabino Mullane" <greg(at)turnstep(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Cc: | fbax(at)sympatico(dot)ca |
Subject: | Re: cli in sql? |
Date: | 2005-11-11 20:03:14 |
Message-ID: | 1bb9fe33ef04362819dae06d5326b2ac@biglumber.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)turnstep(dot)com
PGP Key: 0x14964AC8 200511111457
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFDdPkRvJuQZxSWSsgRAufUAJ9f4/IaYrJDMi3Yg74x0tkN4tmUcQCgmlu9
wAkqRHgYQY9DtdIIfH/g7xY=
=n/J7
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2005-11-11 21:31:35 | Re: cli in sql? |
Previous Message | Warren Murray | 2005-11-11 18:26:15 | Export to XML |