Start of change

IFS_PATH scalar function

The IFS_PATH scalar function returns a specified part of the input path string.

It is assumed that the path string represents an object in the integrated file system (IFS). It can be an absolute path, a relative path, or only an IFS object.

In order to use the IFS_PATH function, the International Components for Unicode (ICU) option (5770SS1 Option 39) must be installed.

Authorization: See Note below.

Read syntax diagramSkip visual syntax diagram IFS_PATH ( PATH_NAME =>  path-name ,SUBSECTION => subsection )
The schema is SYSTOOLS.
path-name
A character string containing a path.
subsection
A character string that indicates which part of path-name is to be returned. No special handling is done when '.' or '..' is included as a directory name within the path string.
The following path string is used as an example to describe the subsection values: /home/mydir/myfile.txt
FILE EXTENSION
The final part of the file name.
For the example, it is txt
FILE NAME
Returns the FILE PREFIX and FILE EXTENSION.
For the example, it is myfile.txt
FILE PREFIX
The part of the file name prior to the file extension.
For the example, it is myfile
PATH PREFIX
The directory path prior to the file name.
For the example, it is /home/mydir/
The result of the function is VARCHAR(5000). If the requested subsection does not exist, an empty string is returned.

Note

This function is provided in the SYSTOOLS schema as an example of using regular expressions in an SQL scalar function. Similar to other Db2® for i provided tools within SYSTOOLS, the SQL source can be extracted and used as a model for building similar helper functions, or to create a customized version within a user-specified schema.

Services provided in SYSTOOLS have authorization requirements that are determined by the interfaces used to implement the service. To understand the authority requirements, extract the SQL for the service and examine the implementation.

Example

Build a path string that represents a new file, status_yymmdd.txt, in the same directory as the provided path.

VALUES SYSTOOLS.IFS_PATH( PATH_NAME => '/usr/mydir/prior_resultfile.txt', 
                          SUBSECTION => 'PATH PREFIX')
    CONCAT 'status_' CONCAT VARCHAR_FORMAT(current date, 'YYMMDD') CONCAT '.txt';
End of change