求大神帮小弟我把一个mysql的function专程oracle的吧
求大神帮我把一个mysql的function专程oracle的吧
mysql 的 function 如下:
BEGIN
declare j INT default 0;
declare i INT default 1;
declare len INT default 0;
declare len1 INT default 0;
declare strname VARCHAR(4000);
declare strval VARCHAR(4000);
set len = LENGTH(p_str);
set len1 = LENGTH(p_delimiter);
lable:WHILE j < len Do
set j = locate(p_delimiter,p_str, i);
IF j = 0
THEN
set j = len;
select name into strval from cms_tlrctl where tlrno=substr(p_str, i);
set strname = concat(ifnull(strname,''),',',strval);
IF i >= len
THEN
leave lable;
END IF;
ELSE
select name into strval from cms_tlrctl where tlrno=substr(p_str, i, j - i);
set strname = concat(ifnull(strname,''),',',strval);
set i = j + len1;
END IF;
END while lable;
RETURN strname;
END
参数是: p_str VARCHAR(4000), p_delimiter VARCHAR(2)
返回类型是: varchar(4000)
求大神帮帮小弟吧
------解决方案--------------------
mysql 的 function 如下:
BEGIN
declare j INT default 0;
declare i INT default 1;
declare len INT default 0;
declare len1 INT default 0;
declare strname VARCHAR(4000);
declare strval VARCHAR(4000);
set len = LENGTH(p_str);
set len1 = LENGTH(p_delimiter);
lable:WHILE j < len Do
set j = locate(p_delimiter,p_str, i);
IF j = 0
THEN
set j = len;
select name into strval from cms_tlrctl where tlrno=substr(p_str, i);
set strname = concat(ifnull(strname,''),',',strval);
IF i >= len
THEN
leave lable;
END IF;
ELSE
select name into strval from cms_tlrctl where tlrno=substr(p_str, i, j - i);
set strname = concat(ifnull(strname,''),',',strval);
set i = j + len1;
END IF;
END while lable;
RETURN strname;
END
参数是: p_str VARCHAR(4000), p_delimiter VARCHAR(2)
返回类型是: varchar(4000)
求大神帮帮小弟吧
------解决方案--------------------
CREATE OR REPLACE FUNCTION fun_mysql
(
p_str IN VARCHAR2,p_delimiter IN VARCHAR2
)
RETURN VARCHAR2
IS
j INT DEFAULT 0;
i INT DEFAULT 1;
len INT DEFAULT 0;
len1 INT DEFAULT 0;
strname VARCHAR2(4000);
strval VARCHAR2(4000);
BEGIN
len:=length(p_str);
len1:=length(p_delimiter);
<<lable>>
WHILE j<len
LOOP
j:=instr(p_delimiter,p_str,i);
IF j=0 THEN
j:=len;
SELECT NAME INTO strval FROM cms_tlrctl WHERE tlrno=substr(p_str,i);
strname:=nvl(strname,'')
------解决方案--------------------
','
------解决方案--------------------
strval;
IF i>=len THEN
EXIT lable;
END IF;
ELSE
SELECT NAME INTO strval FROM cms_tlrctl WHERE tlrno=substr(p_str, i, j - i);
strname := nvl(strname,'')
------解决方案--------------------
','
------解决方案--------------------
strval;
i:= j + len1;
END if;
END LOOP lable;
RETURN strname;
END;