CUBRID學習筆記 18 sql語句的預處理(類似存儲過程)


 

   定義預處理  類似sqlserver的存儲過程

  語法

PREPARE stmt_name FROM preparable_stmt

說明
PREPARE  關鍵字 
stmt_name 預處理語句的名字 昵稱;)
FROM   關鍵字
preparable_stmt  要預處理的語句
PREPARE stmt FROM 'SELECT * FROM game WHERE host_year = ?';

執行預處理

  語法
EXECUTE stmt_name [USING value [, value] …]
說明 execute 關鍵字
stmt_name 預處理名字
using 關鍵字
value 參數值

EXECUTE stmt USING 2004;

歡迎轉載 ,轉載時請保留作者信息。本文版權歸本人所有,如有任何問題,請與我聯系wang2650@sohu.com 。 過錯

 


執行結果


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>











注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
  © 2014-2022 ITdaan.com