Last active
March 1, 2023 08:13
-
-
Save Jonathan-49/daa169b3f0033e069fd3a84a7166e618 to your computer and use it in GitHub Desktop.
Find all csv files in a folder using Db2 for i SQL and strip the suffix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with f1 as | |
(SELECT replace(RTRIM(SUBSTR(lower(path_name), | |
LOCATE_IN_STRING(path_name, '/', -1) + 1, LENGTH(path_name))), '.csv', '') AS File_name_no_suffix, | |
path_name, t.* | |
FROM TABLE ( | |
QSYS2.IFS_OBJECT_STATISTICS( | |
START_PATH_NAME => | |
'/folder', | |
SUBTREE_DIRECTORIES => 'NO', | |
object_type_list => '*ALLSTMF') | |
) as t | |
WHERE | |
regexp_like(path_name, '/.*\.(csv)$', 'i') | |
) | |
--select * from f1 | |
select cast(File_name_no_suffix as char(100) ) from f1 | |
order by file_name_no_suffix |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment