DECLARE
names VARCHAR2(60) := 'Anna,Matt,Joe,Nathan,Andrew,Aaron,Jeff';
names_adjusted VARCHAR2(61);
comma_location NUMBER := 0;
prev_location NUMBER := 0;
BEGIN
--Stick a comma after the final name
names_adjusted := names || ',';
LOOP
comma_location := INSTR(names_adjusted,',',comma_location+1);
EXIT WHEN comma_location = 0;
DBMS_OUTPUT.PUT_LINE(
SUBSTR(names_adjusted,prev_location+1,
comma_location-prev_location-1));
prev_location := comma_location;
END LOOP;
END;
ORACLE INSTR AND SUBSTR DEAL WITH STRINGS
原创文章标签 ORACLE PL/SQL 文章分类 Oracle 数据库
©著作权归作者所有:来自51CTO博客作者toratto的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇:oracle cursor
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章