Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

EXECUTE Statement

Description

The EXECUTE statement executes the prepared statement. You can bind the data value after the USING clause if a bind parameter (?) is included in the prepared statement. You cannot specify user-defined variables like an attribute in the USING clause. An value such as literal and an input parameter only can be specified.

Syntax

EXECUTE stmt_name [USING value [, value] …]

  • stmt_name: The name given to the prepared statement to be executed is specified. An error message is displayed if the stmt_name is not valid, or if the prepared statement does not exist.
  • value: The data to bind is specified if there is a bind parameter in the prepared statement. The number and the order of the data must correspond to that of the bind parameter. If it does not, an error message is displayed.
Example

PREPARE st FROM 'SELECT 1 + ?';

EXECUTE st USING 4;

   1+ ?:0

==========================

   5

 

SET @a=3;

EXECUTE st USING @a;

   1+ ?:0

==========================

   4

 

PREPARE st FROM 'SELECT ? + ?';

EXECUTE st USING 1,3;

   ?:0 + ?:1

==========================

   4

 

PREPARE st FROM 'SELECT ? + ?';

EXECUTE st USING 'a','b';

   ?:0 + ?:1

==========================

   'ab'

 

PREPARE st FROM 'SELECT FLOOR(?)';

EXECUTE st USING '3.2';

   floor( ?:0 )

==========================

   3.000000000000000e+000

 

PREPARE st FROM 'SELECT FLOOR(?)';

EXECUTE st USING 3.2;

   floor( ?:0 )

==========================

   3.0