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. osx下查看jar文件

    jar是java class的打包文件,我们能够将自己的项目打包为jar文件执行,也能够打包后当做第三方包查看,有时候我们须要查看一下一个jar文件里是否还有某个类以及对应的包,我们能够採用下面两种方 ...

  2. js-知识集锦

      CreateTime--2016年9月22日14:37:51Author:Marydonjs小知识点集锦1. JSON.stringify(Obj);//将Object对象转换成json格式的st ...

  3. 新浪微博api出现认证失败问题 (获取code字段值的问题)

    出现该提示的原因:`` - 说: (2015-10-30 18:06:14)回调地址不一致,`` - 说: (2015-10-30 18:07:38)请在编辑开发者信息中将网站地址和应用信息--高级信 ...

  4. 30、Java中Set集合之HashSet、TreeSet和EnumSet

    Set集合是Collection的子集,Set集合与Collection基本相同,没有提供任何额外的方法,只是Set不允许包含重复的元素. Set集合3个实现类:HashSet.TreeSet.Enu ...

  5. 【cookie】cookie和session的终极区别

    如果浏览器使用的是 cookie,那么所有的数据都保存在浏览器端,比如你登录以后,服务器设置了 cookie用户名(username),那么,当你再次请求服务器的时候,浏览器会将username一块发 ...

  6. PHP原生:分享一个轻量级的缓存类=>cache.php

    适用:原生PHP cache.php tips:代码最后有适用Demo哦. <?php /* * 缓存类 cache */ define("cacheRoot"," ...

  7. PHP 与 UTF-8

    没有一行式解决方案.小心.注意细节,以及一致性. PHP 中的 UTF-8 糟透了.原谅我的用词. 目前 PHP 在低层次上还不支持 Unicode.有几种方式可以确保 UTF-8 字符串能够被正确处 ...

  8. HDUOJ-----2065"红色病毒"问题

    "红色病毒"问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. [转]动态加载javascript

    动态加载script到页面大约有俩方法 第一种就是利用ajax方式,把script文件代码从后台加载到前台,然后对加载到的内容通过eval()执行代码. 第二种是,动态创建一个script标签,设置其 ...

  10. Oracle截取字符串函数和查找字符串函数,连接运算符||

    参考资料:Oracle截取字符串和查找字符串 oracle自定义函数学习和连接运算符(||) oracle 截取字符(substr),检索字符位置(instr) case when then else ...