Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using regular expressions in select statements

Status
Not open for further replies.

dendenners

Programmer
Jul 17, 2001
110
IE
Hi there.
I would like to check some file names that I receive against values in a database. I have a database table that holds valid file names, and I need to check specific file names against values in this table. However my problem is that some of the files I receive have a timestamp as part of their name. For example, I may receive a file with the name 'foo20020605120000.dat', where the numbers are a timestamp. What I would like to have is a value in the database like 'foo*.dat' which would positively match the above file. I know this is possible the other way around using the 'LIKE' keyword, but I have never seen an example the way I want it. Thanks for your help.
P.S. if I was able to have a value in the table of
'fooYYYYMMDDhhmmss.dat' that would match the above file, it would be even better.
 
Thanks for the post. However I don't think I explained myself terribly well in the last post. You see I want to restrict the number of allowable file names to a certain pattern matching the reg exp you mentioned above, (foo%dat),
along with various other miscellaneous patterns that are allowable (I should be able to add new allowable values simply by adding a row to a table).
So in my sql statement the actual file name has to be passed in exactly as it first appears (foo20020605120000.dat in the above case) I would then like to check this against the reg exps in the table with something like 'select * from VALID_FILES where FILE_PATTERN LIKE foo20020605120000.dat' where FILE_PATTERN would contain foo%.dat. Alas oracle only reads a % from a row as a literal percent, and does not allow expansion.
I have a different solution arrived at by having 2 cols, a FILE_MAX and FILE_MIN. This way I would use 'select FILE_NAME where FILE_MAX > foo20020605120000.dat and FILE_MIN < foo20020605120000.dat'. maybe thats the best solution. Thanks anyway

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top