Loading topic
DECLARE, BEGIN, END), declare variables with %TYPE, and use IF and LOOP. The examples use the Oracle HR sample schema and DBMS_OUTPUT. In SQLPlus or SQLDeveloper, run SET SERVEROUTPUT ON first.5 min read%TYPE, simple SQL, and how a WHEN clause selects a handler. Here you learn which runtime errors Oracle names for you, how the most common ones are raised, and the mistake4 min readEXCEPTION section with named WHEN clauses and handle predefined exceptions such as NO_DATA_FOUND. It also assumes you know basic COMMIT and ROLLBACK. The examples use the Oracle HR sample schema (employees, departments).4 min readNO_DATA_FOUND cover errors that Oracle detects. They don't cover rules that belong to your application, such as "an order can't exceed available stock". For those rules you declare an exception, raise it when the rule is broken, and handle it by name.4 min readEXCEPTION section and WHEN clauses. It also assumes you know the predefined exceptions (NO_DATA_FOUND, TOO_MANY_ROWS) and how to declare a user-defined exception. Familiarity with SQLCODE and SQLERRM helps.4 min readEXCEPTION section, that you know the predefined exceptions such as NO_DATA_FOUND, and that you have declared a user-defined exception at least once. It covers the RAISE statement: its three forms, when to use each, and the mistakes that 5 min readRAISE. It also assumes you know how stored procedures are called and how COMMIT and ROLLBACK work.5 min readEXCEPTION section does not protect an entire block. It protects only the executable section between BEGIN and EXCEPTION. This chapter covers the two places a handler cannot reach: the declaration section of its own block, and the handlers themselves. It assumes you can write WHEN clauses,5 min readDBMS_UTILITY.FORMAT_ERROR_STACK, DBMS_UTILITY.FORMAT_ERROR_BACKTRACE, DBMS_UTILITY.FORMAT_CALL_STACK, and the structured `UTLCALLSTA5 min readEXCEPTION section, you know COMMIT and ROLLBACK, and you have seen RAISE and RAISE_APPLICATION_ERROR. It covers what an error does to uncommitted data, and how to use a savepoint to undo only part of a transaction.5 min readEXCEPTION section, re-raise with RAISE, and use COMMIT and ROLLBACK. It also assumes you have seen SQLERRM and DBMS_UTILITY.FORMAT_ERROR_STACK. Here you combine them so that an error record stays in the database after the failing work is rolled back.5 min readPRAGMA EXCEPTION_INIT, and use collections. It also assumes you know how COMMIT and ROLLBACK behave. The earlier chapters on propagation and transaction control apply directly here.5 min readEXCEPTION section, know the predefined exceptions, and understand RAISE, RAISE_APPLICATION_ERROR, SQLCODE/SQLERRM, and how exceptions propagate through nested blocks. The examples use the HR5 min read