SQL iQuery Script Built-in Function

Index

SPLIT

Split the contents of a Session Variable at the Separator

The SPLIT() built-in functions reads the Session Variable and returns the text up to the separator and then remove the data including the separator from the Session Variable.

Syntax

The SPLIT() built-in function reads characters from the Session Variable until it detects the character(s) specified on the Separator parameter or hits the end of the value.
The input Session Variable is reduced by the same set of characters. 

Parameters

  1. A session variable.
  2. The separator (one or more characters) that is used to end the values returned by the built-in function. If this parameter is not specified, a comma and blank are used.
  -- This routine extracts the Library, File and Member names along with the SEU Type
#define &source = QGPL/QRPGLESRC(DEMO.RPGLE)

eval &srclib  = split(&source,"/().,");
eval &srcFile = split(&source,"/().,");
eval &srcMbr  = split(&source,"/().,");
eval &srcType = split(&source,"/().,");
#Msg Source Mbr: &srcMbr SEU(&srcType) in &srclib/&srcfile

The &SOURCE session variable contains a qualified file with a member and SEU type. To extract the individual elements of this name, the SPLIT built-in function is called once for each value.
The output written to the joblog would be:

Source Mbr: DEMO SEU(RPGLE) in QGPL/QRPGLESRC