how to match multiple wildcards via metadata table [message #650699] |
Fri, 29 April 2016 15:55 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
I want a user to be able to enter patterns into a table via a form that I will use in a query to find all matching rows in a table, but I have only done this via hardcoding in a regexp_like condition, such as:
create table test_multi (
col1 varchar2(20),col2 number(11));
insert into test_multi values ('GARY',10);
insert into test_multi values ('FRED',20);
insert into test_multi values ('NED',30);
insert into test_multi values ('JOHNNIE',40);
insert into test_multi values ('JILL',500);
select * from test_multi
where regexp_like(COL1,'^(JI|G)');
COL1 COL2
-------------------- ----------------
GARY 10
JILL 500
What if I wanted the user to be able to change the matching condition whenever they wanted and now wants to use this? I don't know why I never needed this before and now I just cannot think of a way to do it.
select * from test_multi
where regexp_like(COL1,'(ED)$');
COL1 COL2
-------------------- ----------------
FRED 20
NED 30
Can I store the patterns in a table and somehow utilize the table in the condition?
Colunn could contain value ^(JI|G) or (ED)$ or any other regular expression??
|
|
|
|
Re: how to match multiple wildcards via metadata table [message #650732 is a reply to message #650700] |
Mon, 02 May 2016 08:13 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Nope Barbara, you got me, even though my explanation left a bit to be desired. It was 5 minutes before the end of the day on Friday, at the end of a long week, so my question was a little disjointed.
All I wanted was for a user definable list of regular expressions to be stored in a table. I should not even have mentioned a form as it was irrelevant to the question.
|
|
|
|
Re: how to match multiple wildcards via metadata table [message #650744 is a reply to message #650737] |
Mon, 02 May 2016 15:36 |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
Ugh, can I use the excuse that I was less than 15 minutes into my week and still in weekend mode, because my wacky grasp of grammar made my response sound like Barbara's answer was not what I was looking for.
However, her answer was exactly what I was looking for.
Sorry, I have been away from here for a loooooong time. I forgot how to make unambiguous, non-obscure postings. I need practice. Normally, I only answer questions, not ask them (I think I maybe asked 3 questions), so I am very inept at conveying my gratitude.
|
|
|
|