存储过程实现oracle的instr函数

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值