EXECUTE
Function
EXECUTE 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 creating the prepared statement declares some parameters, the parameter set passed to the EXECUTE statement must be compatible. Otherwise, an error will occur.
Syntax
EXECUTE name [ ( parameter [, ...] ) ];
Parameter Description
- 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 21 22 23 24 25 26 27 |
-- Create a schema. gaussdb=# CREATE SCHEMA tpcds; -- Create the reason table. gaussdb=# CREATE TABLE tpcds.reason ( CD_DEMO_SK INTEGER NOT NULL, CD_GENDER character(16) , CD_MARITAL_STATUS character(100) ); -- Insert data. gaussdb=# INSERT INTO tpcds.reason VALUES(51, 'AAAAAAAADDAAAAAA', 'reason 51'); -- Create the reason_t1 table. gaussdb=# CREATE TABLE tpcds.reason_t1 AS TABLE tpcds.reason; -- Create a prepared statement for an INSERT statement and execute the prepared statement. gaussdb=# PREPARE insert_reason(integer,character(16),character(100)) AS INSERT INTO tpcds.reason_t1 VALUES($1,$2,$3); gaussdb=# EXECUTE insert_reason(52, 'AAAAAAAADDAAAAAA', 'reason 52'); -- Delete the reason and reason_t1 tables. gaussdb=# DROP TABLE tpcds.reason; gaussdb=# DROP TABLE tpcds.reason_t1; -- Delete the schema. gaussdb=# DROP SCHEMA tpcds CASCADE; |
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