Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

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

PREPARE Statement

Description

The PREPARE statement prepares the query specified in preparable_stmt of the FROM clause, and assigns the name to be used later when the SQL statement is referenced to stmt_name.

Syntax

PREPARE stmt_name FROM preparable_stmt

  • stmt_name : The prepared statement is specified. If an SQL statement with the same stmt_name exists in the given client session, clear the existing prepared statement and prepare a new SQL statement. If the PREPARE statement is not executed properly due to an error in the given SQL statement, it is processed as if the stmt_name assigned to the SQL statement does not exist.
  • preparable_stmt : You must use only one SQL statement. Multiple SQL statements cannot be specified. You can use a question mark (?) as a bind parameter in the preparable_stmt statement and it should not be enclosed with quotes.
Example

--prepare and execute a statement without any parameter marker

PREPARE stmt1 FROM 'SELECT CURRENT_TIMESTAMP ()';

EXECUTE stmt1;

;ru

 

Current transaction has been committed.

 

=== <Result of SELECT Command in Line 2> ===

 

   SYS_TIMESTAMP

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

  03:49:28 PM 04/02/2010

 

--prepare and execute a statement with a parameter marker

PREPARE stmt1 FROM 'SELECT POWER(?,2)*PI()';

EXECUTE stmt1 USING 2;

;ru

 

=== <Result of SELECT Command in Line 2> ===

 

     power( ?:0 , 2)* pi()

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

     1.256637061435917e+01