EXECUTE
Description
Executes a prepared statement. Because a prepared statement exists only in the lifetime of the session, the prepared statement must be created earlier in the current session by using the PREPARE statement.
Precautions
If the PREPARE statement declares some parameters when the prepared statement is created, the parameter set passed to the EXECUTE statement must be compatible. Otherwise, an error occurs.
Syntax
EXECUTE name [ ( parameter [, ...] ) ];
Parameters
- name
Specifies the name of the prepared statement to be executed.
- parameter
Specifies a parameter of the prepared statement. It must be an expression that generates a value compatible with the data type of the parameter specified when the prepared statement was created. ROWNUM cannot be used as a parameter.
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
-- Create the reason table. gaussdb=# CREATE TABLE reason ( CD_DEMO_SK int NOT NULL, CD_GENDER varchar(10), CD_MARITAL_STATUS varchar(10) ); -- Create a prepared statement for an INSERT statement and execute the prepared statement. gaussdb=# PREPARE insert_reason(int,varchar(10),varchar(10)) AS INSERT INTO reason VALUES($1,$2,$3); gaussdb=# EXECUTE insert_reason(52, 'AAAAAAAADD', 'reason 52'); -- Query data. gaussdb=# SELECT * FROM reason; cd_demo_sk | cd_gender | cd_marital_status ------------+------------+------------------- 52 | AAAAAAAADD | reason 52 (1 row) -- Delete the reason table. gaussdb=# DROP TABLE reason; |
Helpful Links
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.
For any further questions, feel free to contact us through the chatbot.
Chatbot