SPOOLED_FILE_DATA table function

The SPOOLED_FILE_DATA table function returns the content of a spooled file.

If the spooled file contains double byte data, the job CCSID must be a mixed CCSID.

Authorization: See Note below.

Read syntax diagramSkip visual syntax diagram SPOOLED_FILE_DATA ( JOB_NAME =>  job-name ,SPOOLED_FILE_NAME => spooled-file-name,SPOOLED_FILE_NUMBER => spooled-file-number )
The schema is SYSTOOLS.
job-name
A character string containing a qualified job name. Can contain the following special value:
*
Use the name of the current job.
spooled-file-name
A character string containing the name of the spooled file. If this parameter is omitted, QPJOBLOG is used.
spooled-file-number
The number of the spooled file. If this parameter is omitted, the spooled file with the highest number matching spooled-file-name is used.
The result of the function is a table containing a row for each record in the specified spooled file. The columns of the result table are described in the following table. The result columns are nullable.
Table 1. SPOOLED_FILE_DATA table function
Column Name Data Type Description
ORDINAL_POSITION INTEGER Relative position of this row in the spooled file.
SPOOLED_DATA VARCHAR(200) The data for this row in the spooled file.

Note

This function is provided in the SYSTOOLS schema as an example of how spooled file data can be returned by embedding the CPYSPLF CL command in an SQL table 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

Return the most recent QSYSPRT file for a specific job:
SELECT * FROM TABLE(SYSTOOLS.SPOOLED_FILE_DATA(
                             JOB_NAME          =>'193846/SLROMANO/QPADEV0009', 
                             SPOOLED_FILE_NAME =>'QSYSPRT'))
ORDER BY ORDINAL_POSITION;