IFS Directory Entries (IFSPATH) UDTF

Index

Schema IQUERY

IFSPATH( path_name => '*HOME', 
        subtree  => '*NO' | '*YES', 
        objtype  => '*ALL' | '*DIR' | '*STMF', 
        omit_list  => '*NONE' | 'omit_pattern' )

The IFS Directory Path Entries (IFSPATH) User Defined Table Function returns one row for each object in the specified PATH_NAME. If SUBTREE=>'*YES' is specified, then the files in the sub-directories within the main path-name are also included.

Parameters

PATH_NAME

Default: '*HOME'

The path name whose file and folders names are listed. If the default *HOME is specified, the home folder associated with the User Profile is used.

SUBTREE

Default: '*NO'

The when *YES is specified, then any folders within the PATH_NAME value will also be included in the resultSet as will any files in those subfolders.

OBJTYPE

Default: *ALL

The object type of the IFS object being returned. The valid choices are *DIR (for folders/directories) and *STMF (stream file names). When *ALL is specified or no OBJTYPE parameter is specified then both folders and files are returned. The leading asterisk is optional. One or more object types is supported, but *ALL or no object type is the same as specifying both *STMF *DIR.  For example: subtype=>'dir stmf'. The SQL WHERE clause can also accomplish this however the difference is that the row is never returned unless it matches the object type(s) specified.

OMIT_LIST

Default: *NONE

To prevent certain patterns from being returned, the OMIT_LIST can be used or the SQL WHERE clause can be used. The difference is the OMIT_LIST avoids returning the row if it matches the omit_pattern. Note the entry matches the omit_pattern if it begins with the same character string as that specified on the OMIT_LIST parameter. Upper/lower case is ignored.

Examples

Return a list of files in the home directory sorted by the file size in descending order:

select objtype, data_size, objname  
FROM TABLE( iQuery.IFSPATH( objtype => '*stmf' )) homeDir ORDER BY DATA_SIZE desc;

Return the top 100 largest objects on the IFS in all HOME directories for all users:.

select data_size,path_name  
FROM TABLE( iQuery.IFSPATH( path_name=>'/home', objtype=>'*STMF')) bigOnes
ORDER BY data_size
LIMIT 100 rows OPTIMIZE for 100 Rows;
Column
Data Type
Description
OBJTYPE
VARCHAR(10)
The type of object(s) to be returned. DIR or STMF is returned.
OBJNAME
VARCHAR(640) The name of the file or folder.
DATA_SIZE
BIGINT The size of the object, in bytes. Note, in RPG IV this would be defined as int(20). In C/C++ it is a long long variable.
OWNER
VARCHAR(10) The owner of the IFS object.
CRTDTS
timeStamp The date the object was created. This is a timestamp value.
ACCDTS
timeStamp
The date and time the object was last access (view, written to, opened).
CHGDTS
timeStamp The date and time the object definition was last changed.
MODDTS
timeStamp
The date and time the data in the object (if it is a STMF) was changed/modified.
FILETYPE
VARCHAR(10)
If the object in the OBJNAME column is a STMF, then this column contains the file suffix. For example, f a file's name is MONTHYENDSALES.XLS, this column contains 'XLS' for that file. Otherwise this column is blank.
OBJNAMELEN
SMALLINT The length of the name of the object as returned in OBJNAME. This column is for selection purposes. For example if you want to check for excessively long file names.
PATH_NAMELEN
SMALLINT
The length of the fully qualified object name returned in the PATH_NAME column.
PATH_NAME
VARCHAR(2048)
The fully qualified object name. This column contains the file name prefixed with the path name vs the OBJNAME column which contains only the object name.