Using the syntax elements defined here, the process is as follows:
- Declare the variable statement_string in the client application language.
- Define statement_string as the literal character text of the SQL statement to be executed, still in the client application language.
- Execute the PREPARE statement from within SQL, defining the host variable statement_string as the SQL variable statement_name.
PREPARE compiles the source code from statement_name into executable object code.
- Execute the EXECUTE or EXECUTE IMMEDIATE statement for statement_name.
- The database software posts return codes to SQLCODE and SQLSTATE.