Eliminate redundant validation with SQL PREPARE statements

The processing which occurs when an SQL PREPARE statement is run is similar to the processing which occurs during precompile processing.

The following processing occurs for the statement that is being prepared:

Again when the statement is executed or opened, the database manager will re-validate that the access plan is still valid. Much of this open processing validation is redundant with the validation which occurred during the PREPARE processing. The DLYPRP(*YES) parameter specifies whether PREPARE statements in this program will completely validate the dynamic statement. The validation will be completed when the dynamic statement is opened or executed. This parameter can provide a significant performance enhancement for programs which use the PREPARE SQL statement because it eliminates redundant validation. Programs that specify this precompile option should check the SQLCODE and SQLSTATE after running the OPEN or EXECUTE statement to ensure that the statement is valid. DLYPRP(*YES) will not provide any performance improvement if the INTO clause is used on the PREPARE statement or if a DESCRIBE statement uses the dynamic statement before an OPEN is issued for the statement.

Related reference
Effects of precompile options on database performance
Related information
Prepare statement