zoukankan      html  css  js  c++  java
  • 游标的使用

    游标:

      类似于数组的下标。

    declare cur_test CURSOR for select id ,username from erp_manages; 定义游标;

    declare continue handler FOR SQLSTATE '02000' set done=1;   当数据扫描到低端标志结束;

    DROP PROCEDURE if exists test_cursor;  Mysql存储过程无法更改内容,只能删除重建。

     1 delimiter |
     2 
     3 create procedure test_cursor(in param int(10),out result varchar(90))
     4 
     5 begin
     6         declare cid int(20);
     7         declare cusername varchar(20);
     8         declare done int;
     9         declare cur_test CURSOR for select id ,username from erp_manages;
    10         declare continue handler FOR SQLSTATE '02000' set done=1;
    11         if param then
    12                 select concat_ws(',',id,username)into result from erp_manages where id=param;
    13         else
    14                 open cur_test;
    15                 repeat
    16                         fetch cur_test into cid,cusername;
    17                         select concat_ws(',',result,cid,cusername)into result;
    18                 until done end repeat;
    19                 close cur_test;
    20         end if;
    21 end; |
    
    
    
  • 相关阅读:
    自动生成接口文档
    Haystack全文搜索
    redis操作
    缓存及跨域问题
    url控制器、解析器、响应器、分页器
    频率组件
    序列化、认证、权限、视图回顾
    认证、权限、视图组件
    序列化组件
    Rest Framework
  • 原文地址:https://www.cnblogs.com/canbefree/p/3831960.html
Copyright © 2011-2022 走看看