ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Informix Procedure exmaple

Informix Procedure exmaple

原创 Linux操作系统 作者:mrhutoo 时间:2013-10-28 16:14:28 0 删除 编辑
Procedure:返回字符串中存在第几个子串的位置
CREATE PROCEDURE instr(vchar varchar(250),chr VARCHAR(250),num INTEGER)
returning integer;
DEFINE out_number INTEGER;
DEFINE here_length INTEGER;
DEFINE end_length INTEGER;
DEFINE here_char VARCHAR(250);
DEFINE num_flag INTEGER;
LET num_flag = 1;
LET here_length = 1;
LET end_length = length(chr);
LET out_number = -10000;
while here_length + end_length - 1 <= length(vchar)
  LET here_char = substr(vchar,here_length,end_length);
  IF here_char = chr AND num_flag = num THEN
    LET out_number = here_length;
    LET here_length = length(vchar) + 1;
  ELIF here_char = chr AND num_flag != num THEN
    LET num_flag = num_flag + 1;
  END IF;
  LET here_length = here_length + 1;
END WHILE;
RETURN out_number;
END PROCEDURE;
 

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

上一篇: CRM客户关系管理
请登录后发表评论 登录
全部评论

注册时间:2010-11-20

  • 博文量
    27
  • 访问量
    67037