Help Center/
GaussDB/
Developer Guide(Centralized_8.x)/
Application Development Guide/
ECPG-based Development/
Executing Dynamic SQL Statements/
Executing a Statement with Input Parameters
Updated on 2024-08-20 GMT+08:00
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. Example:
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'; /* If a prepared statement is no longer used, deallocate it in time. */ EXEC SQL DEALLOCATE PREPARE name;
Parent topic: Executing Dynamic SQL Statements
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot