Executing a Statement with Input Parameters
Prepare a normal statement and execute a specific version of it by replacing its parameters (with question marks). Use the EXECUTE statement to execute the prepared statement by specifying parameters in the USING clause.
EXEC SQL BEGIN DECLARE SECTION; const char *stmt = "INSERT INTO test1 VALUES(?, ?);"; EXEC SQL END DECLARE SECTION; /* PREPARE Prepare a statement for execution. */ EXEC SQL PREPARE mystmt FROM :stmt; ... /* Single quotation marks are valid characters. If a character string is used, use double quotation marks. */ EXEC SQL EXECUTE mystmt USING 42, 'foobar'; /* When you no longer need a prepared statement, you should deallocate it. */ EXEC SQL DEALLOCATE PREPARE name;
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.