Select all strings that appear a substrings of a given string [message #402873] |
Tue, 12 May 2009 22:27 |
ShiningMasamune
Messages: 6 Registered: May 2009 Location: New Jersey
|
Junior Member |
|
|
Greetings all, I'm a bit new to databases so please be gentle!
I have a table with a column of strings, and one big string given to me. I would like to select all strings in the column that are substrings of the given big string. Basically I want this:
SELECT str FROM table WHERE CONTAINS(?, str, 1) > 0
Where ? would be replaced with my given string. Except, this query gives me
Error: ORA-20000: Oracle Text error:
DRG-10599: column is not indexed
In an absolutely ideal world, I want only strings that are whole-word substrings. In other words, if my given string is "I sold shoes to make money" and the str column contains the strings "make money" and "old shoes" I would want only the former selected.
Can this be done? And more importantly, can it be done quickly considering my str column has ten million rows?
Thanks!
[Updated on: Tue, 12 May 2009 22:37] Report message to a moderator
|
|
|
Re: Select all strings that appear a substrings of a given string [message #402878 is a reply to message #402873] |
Tue, 12 May 2009 23:15 |
|
Barbara Boehmer
Messages: 9101 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
Welcome to the ORAFaq forums. In order to use the CONTAINS query operator, you have to first create a CONTEXT index, which is what your error message is telling you. However, that would be the syntax that you would use if your search string where "make money" and your column value was "I sold shoes to make money", not the other way around. You could probably just use the built-in INSTR function or LIKE for what you are trying to do. In the future, pleas post a complete test case, including create table and insert statements for sample data, so that it makes the problem as clear as possible, so that we can provide the most helpful response. Please see the forum guide at the top of each forum for what we expect, or use the link below. I see that you are a student, so please understand that you will learn more if we guide you in the right direction, by suggesting things like INSTR, then expecting you to research that in the online documentation and return with what you have tried, if you still have problems, rather than providing a complete solultion.
Forum Guide:
http://www.orafaq.com/forum/t/88153/0/
|
|
|
|
|
|
|