SQL/MX 2.x Reference Manual (H06.04+)

Embedded-Only SQL/MX Statements
HP NonStop SQL/MX Reference Manual540440-003
3-19
Considerations for DEALLOCATE PREPARE
Considerations for DEALLOCATE PREPARE
Cursor Specification
When you deallocate a prepared statement, any cursor associated with that statement
is canceled.
C Examples of DEALLOCATE PREPARE
Prepare, execute, and deallocate an UPDATE statement with dynamic input
parameters:
...
strcpy(stmt_buffer,"UPDATE SALES.CUSTOMER"
" SET CREDIT = ?"
" WHERE CUSTNUM = CAST(? AS NUMERIC(4) UNSIGNED)")
...
EXEC SQL PREPARE upd_cust FROM :stmt_buffer;
...
/* Input values for parameters into host variables */
scanf("%s",in_credit);
...
scanf("%ld",&in_custnum);
...
EXEC SQL EXECUTE upd_cust USING :in_credit, :in_custnum;
...
EXEC SQL DEALLOCATE PREPARE upd_cust;
This example uses extended statement names:
...
strcpy(stmt,"ins_cust1");
EXEC SQL PREPARE :stmt FROM :stmt_buffer;
EXEC SQL EXECUTE :stmt;
EXEC SQL DEALLOCATE PREPARE :stmt;
...
strcpy(stmt,"ins_cust2");
EXEC SQL PREPARE :stmt FROM :stmt_buffer;
EXEC SQL EXECUTE :stmt;
EXEC SQL DEALLOCATE PREPARE :stmt;
...