Search Postgresql Archives

Re: reverse strpos?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



am  Mon, dem 12.11.2007, um 10:54:53 -0500 mailte Gauthier, Dave folgendes:
> Is there a function that?ll return the position of the last occurance of a char
> in a string? 
> 
>  
> 
> For Example, in the string ?abc/def/ghi? I want the position of the 2^nd ?/?.

write a function to revert the string and use strpos().

create or replace function rev(varchar) returns varchar as $$
declare
        _temp varchar;
        _count int;
begin
        _temp := '';
        for _count in reverse length($1)..1 loop
                _temp := _temp || substring($1 from _count for 1);
        end loop;
        return _temp;
end;
$$ language plpgsql immutable;


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
       choose an index scan if your joining column's datatypes do not
       match

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux