Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

How to Execute Prepared SQL in CUBRID


In order to prepare SQL in CUBRID, we should use the PREPARE syntax:

PREPARE stmt_name FROM preparable_stmt

Remember that the preparable_stmt must be wrapped in single quotes.

To execute the prepared SQL, we should use EXECUTE syntax:

EXECUTE stmt_name [USING value [, value] …]

For example:

PREPARE stmt FROM 'SELECT * FROM game WHERE host_year = ?';
EXECUTE stmt USING 2004;

The following is a sample output obtained from CSQL (CUBRID command line SQL interpreter).

csql> PREPARE stmt FROM 'SELECT * FROM game WHERE host_year = ?';
Current transaction has been committed.
1 command(s) successfully processed.
csql> EXECUTE stmt USING 2004;
=== <Result of SELECT Command in Line 1> ===
      host_year    event_code    athlete_code     stadium_code    nation_code    medal    game_date
========================================================================
      2004         20000         14544            30135           'AUS'          'B'       08/19/2004
.....
884 rows selected.
Current transaction has been committed.
1 command(s) successfully processed.
csql>

comments powered by Disqus
Page info
viewed 4534 times
translations en
Author
posted 2 years ago by
CUBRID
Contributors
updated 2 years ago by
View revisions
Share this article