INSTR SUBSTR function

General
Enthusiast

INSTR SUBSTR function

We are asked to use only the instr function for splitting a delimited column. Not recommended to use csvld or strtok function.

 

Any help on this?

 

Example:

Input:

/abc//def/ghi//jkl

Expected Output:

abc

 

def

ghi

 

jkl


Tried with below query:

SyntaxEditor Code Snippet

CASE 
   WHEN ban_txt LIKE '%/%/%/%'
   THEN SUBSTRING(ban_txt FROM POSITION('/' IN ban_txt) + 1 FOR POSITION('/' IN 
        SUBSTRING(ban_txt FROM POSITION('/' IN ban_txt) + 1)) - 1)
   WHEN ban_txt LIKE '%/%/%'
   THEN SUBSTRING(ban_txt FROM POSITION('/' IN ban_txt) + 1)
      WHEN ban_txt LIKE '%/%'
   THEN SUBSTRING(ban_txt FROM POSITION('/' IN ban_txt) + 1)END

But it just gives only first text as abc. How query should be modiied to get the other values in other columns? Please help!

 

 

1 REPLY
Junior Contributor

Re: INSTR SUBSTR function

Not recommended to use csvld or strtok function.

 

Why?