See Pl/Sql tips
Write exceptions to the alert.log or trace files
begin
sys.dbms_system.ksdwrt(2,'ORA-PIPPO prova patrol');
end;
2 Will write the text to the alert log.
Use 1 instead of 2 to write to the trace file
Use 3 to write to both.
10g - Format error and exception
begin
....
exception
when others then
begin
sys.dbms_system.ksdwrt(2,DBMS_UTILITY.FORMAT_ERROR_STACK );
sys.dbms_system.ksdwrt(2,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE );
RAISE;
end;
END;
...adding the call stack
sys.dbms_system.ksdwrt(2,DBMS_UTILITY.FORMAT_CALL_STACK);
----- PL/SQL Call Stack -----
object line object
handle number name
0x6f54b8e0 131 procedure MTS_HVIEW_ABN_HISTORY.POPULATE
0x677ca230 1 anonymous block |
| How can I find the exception lines in the code? Please change the owner below select d.*
, decode(sign(instr(upper(text), 'EXCEPTION')), 1, '------') matched_line
from (
select a.owner, a.name, a.type, a.line, a.text
from dba_source a, (
select * from dba_source
--Change your owner here
where owner in ('ALDO', 'ALWORKSHOP')
and upper(TEXT) like '%EXCEPTION%'
and type not in ('JAVA SOURCE')
) b
where a.owner = b.owner
and a.name = b.name
and a.type = b.type
and a.line in (
b.line-1, b.line, b.line+1, b.line+2,
b.line+3, b.line+4
)
group by a.owner, a.name, a.type, a.line, a.text
) d
order by owner, name, line |
Declaring an exception
declare
timeout EXCEPTION;
PRAGMA EXCEPTION_INIT (timeout, -25228);
currWaitSecs number := 0;
singleWait number := 5;
begin
stopApply := false;
while currWaitSecs <= uptimeSeconds loop
begin
dequeueApplySingle(singleWait);
currWaitSecs := currWaitSecs + singleWait;
exception
WHEN timeout THEN
null;
end;
end loop;
end; |
Predefined exceptions ACCESS_INTO_NULL ORA-06530 Attempted to assign values to the attributes of an uninitialized (NULL) object CASE_NOT_FOUND ORA-06592 None of the choices in the WHEN clauses of a CASE statement is selected and there is no ELSE clause COLLECTION_IS_NULL ORA-06531 Attempt to apply collection methods other than EXISTS to an uninitialized (NULL) PL/SQL table or varray CURSOR_ALREADY_OPEN ORA-06511 Exactly what it seems to be. Tried to open a cursor that was already open DUP_VAL_ON_INDEX ORA-00001 An attempt to insert or update a record in violation of a primary key or unique constraint INVALID_CURSOR ORA-01001 The cursor is not open or not valid in the context in which it is being called INVALID_NUMBER ORA-01722 It isn't a number even though you are treating it like one to trying to turn it into one LOGIN_DENIED ORA-01017 Invalid name and/or password for the instance NO_DATA_FOUND ORA-01403 The SELECT statement returned no rows or referenced a deleted element in a nested table or referenced an initialized element in an Index-By table NOT_LOGGED_ON ORA-01012 You lost your connection to the database PROGRAM_ERROR ORA-06501 Internal PL/SQL error ROWTYPE_MISMATCH ORA-06504 The rowtype does not match the values being fetched, or assigned, to it SELF_IS_NULL ORA-30625 Program attempted to call a MEMBER method, but the instance of the object type has not been intialized. The built-in parameter SELF points to the object, and is always the first parameterpassed to a MEMBER method STORAGE_ERROR ORA-06500 A hardware problem: Either RAM or disk drive SUBSCRIPT_BEYOND_COUNT ORA-06533 Reference to a nested table or varray index higher than the number of elements in the collection SUBSCRIPT_OUTSIDE_LIMIT ORA-06532 Reference to a nested table or varray index outside the declared range (such as -1) SYS_INVALID_ROWID ORA-01410 The conversion of a character string into a universal rowid fails because the character string does not represent a valid rowid TIMEOUT_ON_RESOURCE ORA-00051 The activity took too long and timed out TOO_MANY_ROWS ORA-01422 The SQL INTO statement brought back more than one value or row (only one is allowed) VALUE_ERROR ORA-06502 An arithmetic, conversion, truncation, or size-constraint error. Usually raised by trying to cram a 6 character string into a VARCHAR2(5) variable ZERO_DIVIDE ORA-01476 Not only would your math teacher not let you do it. Computer's won't either. Who said you didn't learn anything useful in primary school |