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>










posted @ 2016-03-16 16:45  过错  阅读(343)  评论(0编辑  收藏  举报