HomeMogDBMogDB StackUqbar
v2.1

Documentation:v2.1

Supported Versions:

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 ::= 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 of the same data type as that specified parameter in creating and generating the prepared statement.

Examples

-- Create the reason table.
mogdb=# CREATE TABLE tpcds.reason (
    CD_DEMO_SK          INTEGER          NOT NULL,
    CD_GENDER           character(16)            ,
    CD_MARITAL_STATUS   character(100)
)
;

-- Insert data.
mogdb=# INSERT INTO tpcds.reason VALUES(51, 'AAAAAAAADDAAAAAA', 'reason 51');

-- Create the reason_t1 table.
mogdb=# CREATE TABLE tpcds.reason_t1 AS TABLE tpcds.reason;

-- Create a prepared statement for an INSERT statement and execute the prepared statement.
mogdb=# PREPARE insert_reason(integer,character(16),character(100)) AS INSERT INTO tpcds.reason_t1 VALUES($1,$2,$3);

mogdb=# EXECUTE insert_reason(52, 'AAAAAAAADDAAAAAA', 'reason 52');

-- Delete the reason and reason_t1 tables.
mogdb=# DROP TABLE tpcds.reason;
mogdb=# DROP TABLE tpcds.reason_t1;
Copyright © 2011-2024 www.enmotech.com All rights reserved.