Home » RDBMS Server » Server Administration » reading a substring after you find a token
reading a substring after you find a token [message #374383] Fri, 08 June 2001 19:52 Go to next message
nutan
Messages: 1
Registered: June 2001
Junior Member
select header_data
from table user

header data has a value of abc~USERID~xyz
both abc and xyz can be of any length. But the USERID is always of length 6. I basically want to read only the string of length 6 between the two tildas.
I did this.......
select SUBSTR(header_data, 5,6) but it only works if string before the tilda is of length 3.
So again I want to read 6 chars after the first ~
Thanks in advance for your response
Re: reading a substring after you find a token [message #374392 is a reply to message #374383] Sat, 09 June 2001 21:40 Go to previous message
Bala
Messages: 205
Registered: November 1999
Senior Member
Hi,

Use instr with substr

SQL> select substr('abc~USERID~xyz',instr('abc~USERID~xyz','~') +1 , 6) from dual

SUBSTR
------
USERID

SQL> select substr('abcd~USERID~xyz',instr('abcd~USERID~xyz','~') +1 , 6) from dual
SQL> /

SUBSTR
------
USERID

Bala.
Previous Topic: Seeing everything
Next Topic: feature not enabled:objects
Goto Forum:
  


Current Time: Mon Jul 01 04:00:00 CDT 2024