Subject Re: [firebird-support] string questions
Author Jiri Cincura
On 17.6.2006 10:46 martinknappe wrote:
> hello
> 1)
> in sql, using the %-character, i can search for entries with string
> fields as follows:
> select field from table where field like '%something%'
> now, what can i do if i want to search for entries where the string
> really contains the %-symbol or if, for example, i want to search for
> all entries where the field starts with a wildcard followed by
> 'something' followed by the %-symbol (theoretical question)

Look at the escape keyword.

> 2)
> I need a Firebird function - let's call it replace(string, old, new) -
> that does the following:
> -check whether old is a substring of string and if so, replace (the
> substring, not the whole string) with new
> I would write it myself but I don't really know how string operations
> (like concatenation and so on work in sql and i don't want to write a
> function that's already there)

You can do this using SP, but better way will be the UDF. I think, that in
some all-in-one UDF pack is replace function which you can use and/or modify
exactly to your needs.

Jiri Cincura |