am Mon, dem 12.11.2007, um 8:48:29 -0800 mailte David Fetter folgendes: > > > Is there a function that?ll return the position of the last > > > occurance of a char in a string? > > > > > > > write a function to revert the string and use strpos(). > > > > create or replace function rev(varchar) returns varchar as $$ > > declare > > ... > > $$ language plpgsql immutable; > > > > > > Andreas > > PL/Perl might be easier: > > CREATE OR REPLACE FUNCTION rev(TEXT) > RETURNS TEXT > IMMUTABLE > LANGUAGE plperl > AS $$ > return reverse($_[0]); > $$; heh, the PERL-Guru ;-) > > CREATE OR REPLACE FUNCTION rev(TEXT) > RETURNS TEXT > IMMUTABLE > LANGUAGE SQL > AS $$ > SELECT array_to_string( > ARRAY( > SELECT substr($1,i,1) > FROM generate_series(length($1),1,-1) AS i > ), > '' > ); > $$; Nice. The generate_series()-function are really great. 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 4: Have you searched our list archives? http://archives.postgresql.org/