The OPTIMIZE clause must appear in the outermost compound Explanation: You have used the OPTIMIZE clause in a compound statement that is nested within one or more other compound statements. User Action: Move the OPTIMIZE clause to the outermost compound statement in the procedure.