informix 求子串位置函数

CREATE PROCEDURE "informix".tl_strpos(__SubStr Char(20),__Str VarChar(255),__StartPos int)
returning int;
 define __i int;
 define __j int;
 if (__Str is null) or (__SubStr is null) or (__Str = '') or (__SubStr = '') then
  return 0;
 end if;
 let __j = length(trim(__SubStr));
 for __i = __StartPos to length(__Str)
  if substring(__Str from __i for __j) = trim(__SubStr) then
     return __i;
  end if;
 end for;
 return 0;
end procedure
;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/611609/viewspace-753247/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/611609/viewspace-753247/

你可能感兴趣的:(informix 求子串位置函数)