Skip to content

Instantly share code, notes, and snippets.

@Jonathan-49
Last active March 1, 2023 08:13
Show Gist options
  • Save Jonathan-49/daa169b3f0033e069fd3a84a7166e618 to your computer and use it in GitHub Desktop.
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
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