Home » SQL & PL/SQL » SQL & PL/SQL » how to use substr??
how to use substr?? [message #19751] Fri, 05 April 2002 12:00 Go to next message
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 Go to previous message
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
Previous Topic: Transaction
Next Topic: PLEASE HELP ME WITH INSERT INTO TRIGGER
Goto Forum:
  


Current Time: Mon Mar 18 23:05:40 CDT 2024