请教如何将SQLSERVER的FUNCTION转换成ORACLE的FUNCTION,谢谢!
SQLSERVER:
create function retriveValidCode(@Str varchar(200)) returns varchar(200)
as begin
declare @tmpStr varchar(200)
set @tmpStr=@Str
while 1=1
if (substring(@tmpStr,len(@tmpStr),1)= '0 ')
set @tmpStr=substring(@tmpStr,1,len(@tmpStr)-1)
else
break
return @tmpStr
end
------解决方案--------------------是这个意思吗?
create or replace function retriveValidCode(Str varchar2) return varchar2
is
tmpStr varchar2(200);
begin
tmpStr:=Str;
while 1=1 loop
if (substr(tmpStr,length(tmpStr),1)= '0 ') then
tmpStr:=substr(tmpStr,1,length(tmpStr)-1);
else
return tmpStr;
end if;
end loop;
return tmpStr;
end;