pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Sabino Mullane <greg@turnstep.com>
To: pgsql-sql@postgresql.org
Cc: fbax@sympatico.ca
Subject: Re: cli in sql?
Date: Fri, 11 Nov 2005 20:03:14 -0000
Message-ID: <1bb9fe33ef04362819dae06d5326b2ac@biglumber.com> (raw)
In-Reply-To: <5.2.1.1.0.20051111085132.04119120@pop6.sympatico.ca>


-----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-----





view thread (5+ messages)  latest in thread

Message-ID: <1bb9fe33ef04362819dae06d5326b2ac@biglumber.com>
Permalink:  ../1bb9fe33ef04362819dae06d5326b2ac@biglumber.com/
Also on:    postgresql.org/message-id/1bb9fe33ef04362819dae06d5326b2ac@biglumber.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: greg@turnstep.com, fbax@sympatico.ca
  Subject: Re: cli in sql?
  In-Reply-To: <1bb9fe33ef04362819dae06d5326b2ac@biglumber.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox