Thursday, August 8, 2013

Regual Expression in ORACLE SQL using REGEXP_LIKE function

You might have to create VIEWS too get some specific data from Database and call it from your APPIAN BPM Suite.

 

What is regular expressions?

http://docs.oracle.com/cd/B12037_01/server.101/b10759/conditions018.htm

http://en.wikipedia.org/wiki/Regular_expression

http://www.w3schools.com/jsref/jsref_obj_regexp.asp

 

functions may vary in each language , sql or java or javascript , but the regular expression ex: ‘\d’ will be same.

 

\d means digit.

\d+ means digit one or more times

^\d – means start with digit

^\d+$ - means start(^) and end($) with digit and any number of digits

 

 

select * from TMS_TASKS;

 

 

 

When you use oracle regular expressions like below

The column TASK_GROUP has numeric and text, but if you want to get only the numbers , we use where clause and use REGEXP_LIKE oracle function

Function to use: REGEXP_LIKE(source_string, pattern, matchparameter)

 

 

SELECT * FROM TMS_TASKS WHERE REGEXP_LIKE(TASK_GROUP, '^\d+$', 'i');

 

 

The 3rd parameter  ‘i’ means case insensitive

 

 

The result you get is TASK_GROUP data with numeric or digits.

 

 

Rayudu Addagarla