Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I use SQL to search for a pattern within a field?

Xev BellringerDec 26 2013 — edited Dec 27 2013

Hello, Frank, Solomon, ect

I am now faced with this particular scenario, I've got the SQL to search through a field to find text within the field, but I have to know what it is before it can look for it.

What I have to do is this:

Search through a field, for a pattern, and I won't know what the data is I am looking for. Can this be done in SQL?

For instance, Here is my SQL this far, I was helped allot in order to get to this point.

select table_name,

       column_name,

       :search_string search_string,

       result

  from (select column_name,

               table_name,

               'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str

          from cols

         where table_name in ('TABLE1', 'TABLE2')),

       xmltable (str columns result varchar2(10) path '.')

When you execute the above SQL, you have to pass in a value. What I really need is to alter the above SQL, to make it search for a pattern that exist's within the text of the field itself.

Like for instance, lets say the pattern I am looking for is this" xx-xxxxx-xxxx" and it's somewhere in a field.

I need to alter this SQL to take this pattern and search through all the schemas and tables to look for this pattern match.

Can be done?

This post has been answered by Barbara Boehmer on Dec 26 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 24 2014
Added on Dec 26 2013
34 comments
2,975 views