Hi i have below text and taking filename from below text. but need date extract as well. but instead of hard coded i want as substring function where i can extract date from the text itself.
select
SUBSTR(fname, INSTR(fname, '_', -1)+1) as fname,
'20181217' as fdate
from
(
select '/home/dir/file_name_20181217_product.csv' as fname from dual
);
regexp_substrfunction, maybe? You can only stick with plainsubstrif the file name has a fixed number of underscores in those positions, really; which may be the case for your real names, of course...file_name_20181217_product.csvis the filename. Your current code extracts justproduct.csv- that is not the filename, at least not according to the standard technical definition. You would do well to create a new term for what you need, so as not to cause confusion, both for yourself and for others who may work on the same task, now or in the future.