Skip navigation.

DB2 regexp in select clause

, , , , , , ,

How to use regular expressions in a DB2 select query?
The simple answer is you can't. But if you are very insistent you can acheive that.
A lot of RDBSes have built in support for regular expressions, why doesn't DB2 has one? I have no idea.

In MySQL you do REGEXP, NOT REGEXP or RLIKE. here is another link.

In Microsoft SQL Server 2000 you call xp_pcre. In Microsoft SQL Server 2005 you call integrated .NET Regex classes from .

In PostgreSQL you call the regexp functions, here is another link.

For Oracle here we have a bunch of resources: First, second and also on regular-expressions.info

If you'll do a search on DB2 regexp you will stumbled upon this IBM article:
http://www.ibm.com/developerworks/data/library/techarticle/0301stolze/0301stolze.html
Which I found very interesting.

Immutable StringUSCIS H1B for 2010

Comments

Anonymous 7. May 2009, 12:08

Adrenalin writes:

Regexp are cool, but in the databases it will not use Indexes, if you'll put it in WHERE clause I think a full-table-scan is guaranteed ;)
Oleak in inglish sh eo ;D C'été pas mal quand même ;) Poliglot total ;o)

freejerk 26. June 2009, 14:36

Ap da, sigur. Dar cred ca daca stii unde sa le folosesti ap nu strica. Daca de exemplu ai o tabela mica, dar ai nevoie la gat regexp :smile:

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies