how to use substr?? [message #19751] |
Fri, 05 April 2002 12:00 |
George
Messages: 68 Registered: April 2001
|
Member |
|
|
Hi,
I have strings like abc.x.02 or abc.x, and I want to get the x right after abc. and before next ., this is what I tried and failed:
select substr('abcd.x.02', instr('abcd.x.02', '.', 1)+1, instr('abcd.1.02', '.', 1)+1 ) as Rev_ID from dual ;
how to fix this?
Thanks
|
|
|
Re: how to use substr?? [message #19762 is a reply to message #19751] |
Mon, 08 April 2002 01:47 |
Epe
Messages: 99 Registered: March 2002
|
Member |
|
|
Hello,
select substr('abcd.x.02',instr('abcd.x.02','.',1,1)+1,1) Rev_ID from dual;
The last variable in the substr function should say how many positions from the source string should be taken. If you use there "instr('abcd.1.02','.',1)+1,
then you're asking to retrieve 6 characters instead of the 1 (x) you want.
good luck,
epe
|
|
|