drop procedure if exists p_hello_world;

create procedure p_hello_world()
begin
declare id integer;
declare username varchar(256);
declare result varchar(4000) default '';
/* don't work */
/*declare cur_user cursor for select id from p_user where id is not null and name is not null order by id;*/
declare cur_user cursor for select t.id, t.name from p_user t where t.id is not null and t.name is not null order by t.id;
declare continue handler for SQLSTATE '' set id = null;
open cur_user;
fetch cur_user into id, username;
while (id is not null) do
set result = concat(result, 'id:', id, 'username:', username, ';');
fetch cur_user into id, username;
end while;
close cur_user;
select result;
end; call p_hello_world();

MySQL PLSQL Demo - 003.静态游标的更多相关文章

  1. 【MySQL】MySQL PLSQL Demo - 006.循环(WHILE DO and FOR LOOP)

    WHILE DO drop procedure if exists p_while_do; create procedure p_while_do() begin declare i int; ; d ...

  2. MySQL PLSQL Demo - 005.IF THEN ELSEIF THEN ELSE END IF

    drop procedure if exists p_hello_world; create procedure p_hello_world(in v_id int) begin ) then sel ...

  3. MySQL PLSQL Demo - 002.变量定义、赋值

    drop procedure if exists p_hello_world; create procedure p_hello_world() begin declare v_number int; ...

  4. MySQL PLSQL Demo - 001.创建、调用、删除过程

    drop procedure if exists p_hello_world; create procedure p_hello_world() begin select sysdate(); end ...

  5. Mysql 存储过程中使用多游标

    Mysql 存储过程中使用多游标 drop procedure IF EXISTS test_proc_1; create procedure test_proc_1() begin ; ) ; ) ...

  6. java jdbc使用SSH隧道连接mysql数据库demo

    java jdbc使用SSH隧道连接mysql数据库demo   本文链接:https://blog.csdn.net/earbao/article/details/50216999   packag ...

  7. sulin Python3.6爬虫+Djiago2.0+Mysql --实例demo

    1.切换到项目目录下,启动测试服务器 manage.py runserver 192.168.0.108:8888 2.设置相关配置 项目目录展示如下: beauty=>settings.py ...

  8. Oracle PLSQL Demo - 20.弱类型REF游标[没有指定查询类型,也不指定返回类型]

    declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_ename ); v_deptno ); v ...

  9. Oracle PLSQL Demo - 17.游标查询个别字段(非整表)

    declare Type ref_cur_variable IS REF cursor; cur_variable ref_cur_variable; v_empno scott.emp.empno% ...

随机推荐

  1. 图片预加载插件 preLoad.js

    1.preLoad.js插件 /*! * preLoad.js v1.0 * (c) 2017 Meng Fangui * Released under the MIT License. */ (fu ...

  2. sql优化经历(转存+记录)

    sql优化经历 补充:看到这么多朋友对sql优化感兴趣,我又重新补充了下文章的内容,将更多关于sql优化的知识分享出来, 喜欢这篇文章的朋友给个赞吧,哈哈,欢迎交流,共同进步. 2015-4-30补充 ...

  3. set names utf8 【mysql导入中文乱码问题解决】

    由于工作的关系需要经常导入一些sql脚本,但是经常会遇到导入中文出现乱码的问题,搞得自己每次导入sql脚本时都很害怕,自己也上网找了一些资料,尝 试了许多办法,有些方法可以正常导入中文,有些办法却不行 ...

  4. 域名无法解析 Linux临时或永久修改DNS

    最近给VPS重装了系统,因为服务商不提供DHCP,所以只好手动设置IP和DNS Server.悲催的是系统重装的时候忘记了输入DNS Server,最后导致进去系统后,各种域名无法解析. Linux中 ...

  5. 社区类 App 如何引导用户发帖和产生内容?

    作者:Pmer在路上链接:http://www.zhihu.com/question/25502904/answer/31342246来源:知乎著作权归作者所有,转载请联系作者获得授权. ugc的产出 ...

  6. 架构-LAMP特级学习(网站加速解决方案)

    1.Squid代理缓存技术 2.页面静态化缓存技术 3.Memcache.Redis等缓存服务器 4.Sphinx搜索加速

  7. PHP-Open Flash Chart报表生成

    下载: http://www.cnblogs.com/huangcong/archive/2013/01/27/2878650.html 安装: 解压ZIP包, 将open-flash-chart.s ...

  8. SDL 2.0 API by Category

    Basics View information and functions related to... View the header Initialization and Shutdown SDL. ...

  9. Socket详解-Linux Socket编程(不限Linux)

    “一切皆Socket!” 话虽些许夸张,但是事实也是,现在的网络编程几乎都是用的socket. ——有感于实际编程和开源项目研究. 我们深谙信息交流的价值,那网络中进程之间如何通信,如我们每天打开浏览 ...

  10. IIS6.0中布署MVC站点

    http://www.cnblogs.com/anny-1980/articles/2616657.html