Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Re: [GENERAL] reverse strpos?

From: A. Kretschmer <andreas.kretschmer(at)schollglas.com>
Date: Mon Nov 12 2007 - 11:19:25 EST


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
Received on Mon Nov 12 11:21:17 2007

This archive was generated by hypermail 2.1.8 : Mon Jun 16 2008 - 19:42:52 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library