The EXECDIRECT statement allows you to execute statements inside stored procedures without preparing those statements first. This reduces the amount of code required. If the statement is a cursor, you still need to close and drop it; only the PREPARE statement can be skipped.
Considerations for EXECDIRECT usage:
▪If the statement specifies a cursor name, the cursor must be dropped with the EXEC SQL DROP statement.
▪If a cursor name is not specified, you do not need to drop the statement.
▪If the statement is a fetch cursor, the INTO... clause must be specified.
▪If the INTO clause is specified, the cursor name must be specified; otherwise the FETCH statement is able to specify which cursor name the row should be fetched from. You may have more than one open cursor at a time.