Re: substring replacement

Поиск
Список
Период
Сортировка
От Jeff Eckermann
Тема Re: substring replacement
Дата
Msg-id 20011109163542.41082.qmail@web20805.mail.yahoo.com
обсуждение исходный текст
Ответ на substring replacement  (Oleg Lebedev <olebedev@waterford.org>)
Список pgsql-sql
I assume you mean that '\n' and '\t' exist as literal
characters in your data, and you simply want to delete
them.
There is no builtin function in PostgreSQL which will
delete a substring ("translate" works for characters,
in the manner of Unix "tr").  You will need to write
one for yourself.  A generic function would be
something like this:
CREATE FUNCTION s(text, text, text)
RETURNS text as '
$_[0] =~ s/$_[1]/$_[2]/;
return $_[0];
' LANGUAGE 'plperl';
Substitute whatever datatype you are using.

--- Oleg Lebedev <olebedev@waterford.org> wrote:
> Hi everybody,
> I am wondering if there is an efficient way to get
> rid of line breaks
> ('\n') and tabs ('\t') from a string. Suppose, I
> have the following
> query:
> SELECT description
> FROM device;
> I don't want the returned description column to
> contain '\n' and '\t'.
> Is it possible to do it efficiently?
> thanks,
> 
> Oleg
> 
> 
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
> http://www.postgresql.org/users-lounge/docs/faq.html


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jason Earl
Дата:
Сообщение: Re: Optimization, etc
Следующее
От: Masaru Sugawara
Дата:
Сообщение: Re: Single VIEW, Everybody JOIN!