am 23.03.2005, um 12:37:54 -0500 mailte Wei Weng folgendes:
> I have a table with column filepath with contents that look like the
> following:
>
> filepath
> ==============
> /var/log/foo
> /var/log/bar
> /var/cache/foo
> /var/cache/bar
> /var/foo
> /var/bar
>
> Is there anyway to retrieve the directory information only regarding those
> filepaths?
>
> So that I can get
>
> /var/log
> /var/cache
> /var
>
test_db=# select * from filepath ; path
----------------/var/log/foo/var/log/bar/var/cache/foo/var/cache/bar/var/foo
(5 Zeilen)
test_db=# select substring (path, '/.*/') from filepath ; substring
-------------/var/log//var/log//var/cache//var/cache//var/
(5 Zeilen)
test_db=# select trim(trailing '/'from substring (path, '/.*/')) from filepath ; rtrim
------------/var/log/var/log/var/cache/var/cache/var
(5 Zeilen)
test_db=# select version(); version
------------------------------------------------------------------------------------------------------PostgreSQL 7.4.7
oni386-pc-linux-gnu, compiled by GCC i386-linux-gcc (GCC) 3.3.5 (Debian 1:3.3.5-5)
(1 Zeile)
Regards, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47212, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net=== Schollglas Unternehmensgruppe ===