How To Retrieve string unto first pipe symbol in query [message #675432] |
Fri, 29 March 2019 02:26 |
|
ssyr
Messages: 65 Registered: January 2017
|
Member |
|
|
Hello All,
I need to retrieve string from given string such as my string I like this '123456789|1235465778|' I want data upto prior to first pipe symbol
O/P: 123456789
Could you please help us for this.
Thank you in advance.
|
|
|
|
|
|
|
Re: How To Retrieve string unto first pipe symbol in query [message #675507 is a reply to message #675475] |
Tue, 02 April 2019 14:03 |
|
Littlefoot
Messages: 21811 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
If the string always looks like this, then any of these options would work.
SQL> with test (col) as
2 (select '123456789|1235465778|' from dual)
3 select substr(col, 1, instr(col, '|') - 1) res1,
4 regexp_substr(col, '\d+') res2,
5 regexp_substr(col, '\w+') res3
6 from test;
RES1 RES2 RES3
--------- --------- ---------
123456789 123456789 123456789
SQL>
If it doesn't, then it depends.
[Updated on: Tue, 02 April 2019 14:03] Report message to a moderator
|
|
|