Error Handling

With error handling, if something in a procedure fails, it goes to the routine for handling that exception. In SQL Server, the TRY CATCH block can be used for error handling. This is almost like wrapping the code in a transaction with a BEGIN TRY and then executing some code. If errors come up, it goes to the BEGIN CATCH.

BEGIN TRY  . . . . . . . . (T-SQL CodeEND TRYBEGIN CATCH... ... .(Error handling code)END CATCH

With PL/SQL’s exception handling, the errors that are raised can be user-or system-defined.

DECLARE    ........... (variables defined)BEGIN   ........... (Blocks of code)EXCEPTION     WHEN exception_name THEN         ............(Exception handling code)END;

The error functions in SQL Server and Oracle provide information ...

Get Oracle Database Administration for Microsoft SQL Server DBAs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.