[u][/u]-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `splitStringTotalFunction`(
f_string varchar(1000),f_delimiter varchar(5)
) RETURNS int(11)
BEGIN
declare returnInt int(11);
if length(f_delimiter)=2 then
return 1+(length(f_string) - length(replace(f_string,f_delimiter,'')))/2;
else
return 1+(length(f_string) - length(replace(f_string,f_delimiter,'')));
end if;
END
-- --------------------------------------------------------------------------------
-- Routine DDL
-- Note: comments before and after the routine body will not be stored by the server
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` FUNCTION `splitStringFunction`(
f_string varchar(1000),f_delimiter varchar(5),f_order int) RETURNS varchar(255) CHARSET utf8
BEGIN
declare result varchar(255) default '';
set result = reverse(substring_index(reverse(substring_index(f_string,f_delimiter,f_order)),f_delimiter,1));
return result;
END
set i = 1;
if(i_inventoryID is not null and length(i_inventoryID) <> 0) then
while i <= splitStringTotalFunction(i_inventoryID,',')
do
set dictCode = splitStringFunction(i_inventoryID,',',i);
/*终端料仓库盘盈rfid字符串*/
call stockTerminalGainRfidsProcedure(dictCode,null,null,stockTerminalGainRfids);
if(stockTerminalGainRfids <> '' and stockTerminalGainRfids is not null) then
set stockGainRfids = concat('',stockTerminalGainRfids,'' ,',') ;
end if;
set i = i + 1;
end while;
end if;
set i = 1;
if(i_inventoryID is not null and length(i_inventoryID) <> 0) then
while i <= splitStringTotalFunction(i_inventoryID,',')
do
set dictCode = splitStringFunction(i_inventoryID,',',i);
/*实体库盘盈rfid字符串*/
call stockStoreGainRfidsProcedure(dictCode,null,null,stockStoreGainRfids);
if(stockStoreGainRfids <> '' and stockStoreGainRfids is not null) then
set rfid_temp = concat('',stockStoreGainRfids,'' ,',') ;
end if;
set i = i + 1;
end while;
end if;
if(stockGainRfids <> '' and stockGainRfids is not null) then
set stockGainRfids = concat(stockGainRfids,rfid_temp) ;
else
set stockGainRfids = rfid_temp ;
end if;
set @ch = substring(stockGainRfids, -1, 1);
if(@ch = ',') then
set stockGainRfids = left(stockGainRfids, CHAR_LENGTH(stockGainRfids) - 1);
end if;
分享到:
相关推荐
Mysql存储过程常用语句模板(含变量,if,三种循环等等) Mysql存储过程常用语句模板(含变量,if,三种循环等等) Mysql存储过程常用语句模板(含变量,if,三种循环等等) Mysql存储过程常用语句模板(含变量,if,三...
一个简单易理解的mysql存储过程 循环表操作 使用游标
本资源结合实例实现一个复杂的存储过程,存储过程中有用到游标、临时表、循环、递归等知识,sql文件附有实例数据表创建的sql语句。
MySQL创建存储过程批量插入10万条数据 存储过程 1、首先防止主键冲突,我们清空表。 TRUNCATE table A_student; 2、编写存储过程 delimiter ‘$’; CREATE PROCEDURE batchInsert(in args int) BEGIN declare i int ...
能学到什么:可以学会如何使用MySQL创建无参存储过程、有参存储过程、IF-ELSE存储过程、WHILE循环存储过程、CASE-WHEN条件控制存储过程、REPEAT UNTIL循环存储过程、LOOP循环存储过程。 阅读建议:提前安装好MySQL的...
资源包中囊括了MySQL数据库中的存储过程的使用包含的基本结构及日常所使用到的基本函数的使用【包括java端调用存储过程,创建临时表,动态执行sql语句,过程的递归调用,指针循环取数,批量创建表删除表,树状结构的...
Mysql存储过程常用语句模板(含变量,if,三种循环等等)
MySQL存储过程编写总结文档,包括循环结构样式,创建临时表,删除数据,MySQL分页,动态存储过程编写
主要介绍了MySQL实现创建存储过程并循环添加记录的方法,涉及基本的mysql存储过程创建、调用相关操作技巧,需要的朋友可以参考下
mysql循环添加数据(存储详细),mysql循环添加数据(存储详细)
mysql存储过程,REPEAT+while 实现嵌套循环。循环内嵌套循环。
mysql存储例程、存储过程、存储函数进阶学习
本节主要介绍了Mysql存储过程循环内如何嵌套使用游标,详细实现如下,需要的朋友不要错过
loop 游标双层嵌套循环 创建临时表, 游标
kettle批量导出mysql存储过程,利用kettle的循环批量导出mysql 单个存储过程sql脚本,并生成命令行.source文件
最近遇到这样的问题,在MySQL的存储过程中,游标操作时,需要执行一个conitnue的操作.众所周知,MySQL中的游标循环操作常用的有三种,LOOP,REPEAT,WHILE.三种循环,方式大同小异.以前从没用过,所以记下来,方便以后查阅. 1....
主要介绍了MySQL存储过程中使用WHILE循环语句的方法,实例分析了在MySQL中循环语句的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下
22.MySQL高级存储过程语法while循环.avi 23.MySQL高级存储过程语法repeat循环.avi 24.MySQL高级存储过程语法loop循环.avi 25.MySQL高级存储过程语法游标介绍.avi 26.MySQL高级存储过程语法游标基本操作.avi 27.MySQL...
mysql在5.1之后增加了存储过程的功能, 存储过程运行在mysql内部,语句都已经编译好了,速度比sql更快. 存储过程与mysql相当于shell和linux系统。如果你是程序员的话,那我告诉你存储过程实际上是一个方法,你只要...