When the same static SQL statement (INSERT statement, UPDATE statement, DELETE statement) is executed repeatedly many times, the parsing process can become an overhead and affect the application's processing performance. To reduce the parsing process, prepare the statement to be executed with the PREPARE statement and execute it with the EXECUTE statement.
Example
Examples of PREPARE statement and EXECUTE statement
PREPARE fooplan (int, text, bool, numeric) AS INSERT INTO foo VALUES($1, $2, $3, $4);
EXECUTE fooplan(1, 'Hunter Valley', 't', 200.00);In the precompiler for embedded SQL in C language and COBOL language, there is a feature that automatically prepares statements for execution without rewriting SQL statements. By specifying the "-r prepare" option in the precompile command, SQL statements are prepared before execution, which can improve performance.
Example
In the case of embedded SQL using COBOL language
ecobpg -r prepare testproc.pco