Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Question: How to create this function
Ming Liu wrote:
>
> Hi. Folks:
> I want to create a function call get_item to do the following:
> get_item('A,B,C,D', 1, ',') = 'A'
> get_item('A,B,C,D', 2, ',') = 'B'
> get_item('A,B,C,D', 3, ',') = 'C', ect.
> Thanks for any hints.
Look at INSTR function...
INSTR - Syntax INSTR(char1,char2[,n[,m]])
Purpose
Searches char1 beginning with its nth character for the mth occurrence
of char2 and returns the position of the character in char1 that is the
first character of this occurrence. If n is negative, Oracle7 counts and
searches backward from the end of char1. The value of m must be
positive. The default values of both n and m are 1, meaning Oracle7
begins searching at the first character of char1 for the first
occurrence of char2. The return value is relative to the beginning of
char1, regardless of the value of n, and is expressed in characters. If
the search is unsuccessful (if char2 does not appear m times after the
nth character of char1) the return value is 0.
--
![]() |
![]() |