`

存储过程 入门

 
阅读更多
示例说明:先创建一个临时表,并插入数据,然后查询临时表,返回游标。



create procedure testPrc()
-- 返回一个纪录
dynamic result sets 1
------------------------------------------------------------------------
-- sql 存储过程
------------------------------------------------------------------------
p1: begin
-- 定义一个全局临时表tmp_hy
declare global temporary table session.tmp_hy
    (
       dm varchar(10),
       mc varchar(10)       
     )
     with replace -- 如果存在此临时表,则替换
     not logged;  -- 不在日志里纪录

    -- 给临时表插入三条数据
    insert into session.tmp_hy values('1','1');
     insert into session.tmp_hy values('1','1');
    insert into session.tmp_hy values('1','1');
   
p2: begin  
  -- 声明游标
declare cursor1 cursor with return for
  select * from session.tmp_hy; 
-- 游标对客户机应用程序保持打开
open cursor1;

end p2;
end p1

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics