Open Source RDBMS - Seamless, Scalable, Stable and Free

English | 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
문서 정보
viewed 4017 times
번역 en
작성자
posted 2년 전
CUBRID
공헌자
마지막 수정시간 2년 전
변경 내역 보기
Share this article