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] …]
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>