CPI4324 - Temporary file built for file &1

CPI4324
Message Text: Temporary file built for file &1.
Cause Text: A temporary file was built for member &3 of file &1 in library &2 for reason code &4. This process took &5 minutes and &6 seconds. The temporary file was required in order for the query to be processed. The reason codes and their meanings follow:
  1. The file is a join logical file and its join-type (JDFTVAL) does not match the join-type specified in the query.
  2. The format specified for the logical file references more than one physical file.
  3. The file is a complex SQL view requiring a temporary file to contain the results of the SQL view.
  4. For an update-capable query, a subselect references a field in this file which matches one of the fields being updated.
  5. For an update-capable query, a subselect references SQL view &1, which is based on the file being updated.
  6. For a delete-capable query, a subselect references either the file from which records are to be deleted or an SQL view or logical file based on the file from which records are to be deleted.
  7. The file is user-defined table function &8 in &2, and all the records were retrieved from the function. The processing time is not returned for this reason code.
  8. The file is a partition file requiring a temporary file for processing the grouping or join.
Recovery Text: You may want to change the query to refer to a file that does not require a temporary file to be built.

Before the query processing could begin, the data in the specified table had to be copied into a temporary physical table to simplify running the query. The message help contains the reason why this message was sent.

If the specified table selects few rows, typically less than 1000 rows, then the row selection part of the query's implementation should not take a significant amount of resource and time. However if the query is taking more time and resources than can be allowed, consider changing the query so that a temporary table is not required.

One way to do this is by breaking the query into multiple steps. Consider using an INSERT statement with a subselect to select only the rows that are required into a table, and then use that table's rows for the rest of the query.