oracle query

Sarma Vadlamani
Sarma Vadlamani used Ask the Experts™
on
hi i want to get
the data only from second error i.e., using regexp or substr
ORA-28007:The pwd cannot be reused.
ORA-06502: PL/SQL:numeric or value error ORA-28007:The pwd cannot be reused.

thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2012
Distinguished Expert 2018
Commented:
To get everything after the first carriage return try this:
with mydata as(
select 'ORA-28007:The pwd cannot be reused. 
 ORA-06502: PL/SQL:numeric or value error ORA-28007:The pwd cannot be reused.
' myerror from dual
)
select
substr(myerror,instr(myerror,chr(10))+1)
from mydata;

Open in new window


Do you just want "ORA-06502: PL/SQL:numeric or value error"?  
Literally the second error is ANY stack trace?
johnsoneSenior Oracle DBA

Commented:
Assuming that you have the error message in column COL1, this should do it:

SUBSTR(COL1, INSTR(COL1, 'ORA-', 1, 2))
Most Valuable Expert 2012
Distinguished Expert 2018

Commented:
Just in case you ever want just the second error no matter what:
with mydata as(
select 'ORA-28007:The pwd cannot be reused. 
 ORA-06502: PL/SQL:numeric or value error ORA-28007:The pwd cannot be reused.
' myerror from dual
)
select
regexp_substr(myerror,'(ORA-[0-9]{5}.+)(ORA-[0-9]{5})',1,1,null,1)
from mydata;

Open in new window


This returned:
ORA-06502: PL/SQL:numeric or value error

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial