Fujitsu J2X0-1634-01EN Computer Accessories User Manual


 
[Figure: Procedure for fetching execution results for a prepared statement]
When modifying an SQL statement dynamically to manipulate data, prepare execution of the SQL statement.
Preparing the SQL statement
Use the PREPARE statement to prepare a dynamic SQL statement for execution. To create and execute an SQL
statement when the program is executed, store the SQL statement as a character string in a host variable called the
SQL statement variable. Next, the PREPARE statement to prepare the SQL statement for execution. At this point, the
SQL statement stored in the SQL statement variable is associated with the SQL statement identifier for statement
identification.
If the SQL statement variable is a preparable dynamic UPDATE statement (positioned) or a preparable dynamic
DELETE statement (positioned), the corresponding cursor must be opened in advance. The specified cursor must
also be a dynamic cursor.
If the PREPARE statement is reexecuted for the defined SQL statement identifier, the allocated prepared statement is
deallocated and a new prepared statement is prepared. If the allocated prepared statement is a dynamic SELECT
statement, the statement prepared for a preparable dynamic UPDATE or DELETE statement (positioned) that
139