Created
September 23, 2020 00:52
-
-
Save forstie/762064534afab0def1e61094a8852c3d to your computer and use it in GitHub Desktop.
Someone asked if you could count the stream file objects, by directory. This solution gets the job done and includes the total size count as well.
This file contains 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
-- One time setup | |
cl:ADDDIRE USRID(<user-profile> RST) USRD('Your name') USER(<user-profile>); | |
-- | |
-- description: Count the stream file objects, by subdirectory | |
-- Include the total size of all stream files in each subdirectory | |
-- Order the result by largest object count, descending | |
-- | |
-- Note: Please note that this isn't a fast query and is meant to be run once in a while | |
-- and not During a performance critical period. | |
-- minvrm: v7r3m0 | |
with all_ifs_dirs as | |
(select path_name as dir_path | |
from table ( | |
qsys2.ifs_object_statistics( | |
start_path_name => '/', | |
subtree_directories => 'YES', | |
object_type_list => '*ALLDIR *NOQSYS', | |
ignore_errors => 'YES' | |
)) ) | |
select dir_path, count(*) as stmf_count, sum(data_size) as total_size from | |
all_ifs_dirs, table ( qsys2.ifs_object_statistics( | |
start_path_name => dir_path, | |
subtree_directories => 'NO', | |
object_type_list => '*STMF', | |
ignore_errors => 'YES' | |
)) | |
group by dir_path | |
order by 2 desc ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I wasn't able to get this done in one statement,...
`