Home » SQL & PL/SQL » SQL & PL/SQL » Stripping a field in the format xx.xx.xx. into seperate fields
Stripping a field in the format xx.xx.xx. into seperate fields [message #380113] Fri, 09 January 2009 03:37 Go to next message
matpj
Messages: 115
Registered: March 2006
Location: London, UK
Senior Member

Hi,
I need to process our version number field by looking at different sections of the version number.
for example,
18.0.1
I need to strip out the 18, strip out the 0 and strip out the 1.

can anybody advise how I can acheive this?
I have tried searching but have not found the answer I am looking for.

Regards,
Matt
Re: Stripping a field in the format xx.xx.xx. into seperate fields [message #380118 is a reply to message #380113] Fri, 09 January 2009 03:46 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
http://www.orafaq.com/forum/mv/msg/129556/364805/102589/#msg_364805

Regards
Michel
Re: Stripping a field in the format xx.xx.xx. into seperate fields [message #380123 is a reply to message #380118] Fri, 09 January 2009 03:54 Go to previous messageGo to next message
matpj
Messages: 115
Registered: March 2006
Location: London, UK
Senior Member

Thanks Michel,

I guess my searching wasn;t very effective this time Sad

regards,
Matt
Re: Stripping a field in the format xx.xx.xx. into seperate fields [message #380126 is a reply to message #380123] Fri, 09 January 2009 04:03 Go to previous message
Frank Naude
Messages: 4502
Registered: April 1998
Senior Member
Other methods include the use of SUBSTR and INSTR or even REGEXP_% functions. For example:

SQL> SELECT REGEXP_REPLACE('18.0.1', '(\d+)\.(\d+)\.(\d+)', '\1') FROM dual;

RE
--
18

SQL> SELECT REGEXP_REPLACE('18.0.1', '(\d+)\.(\d+)\.(\d+)', '\2') FROM dual;

R
-
0

SQL> SELECT REGEXP_REPLACE('18.0.1', '(\d+)\.(\d+)\.(\d+)', '\3') FROM dual;

R
-
1
Previous Topic: how to extract line/sting from long
Next Topic: Looping in SQL - Hirerarchical Tree
Goto Forum:
  


Current Time: Thu Dec 08 12:49:10 CST 2016

Total time taken to generate the page: 0.10200 seconds