Types of Exceptions in Pl/SQL - Pl/SQL Tutorial

preview_player
Показать описание
Types of Exceptions in Pl/SQL is a free tutorial by Intellezy Trainers from Pl/SQL course
Link to this course(Special Discount):
This is the best Pl/SQL Course
Course summary:
Prepare your environment
Work with Oracle database tools
Understand and work with language features
Work with the DECLARE clause
Work with the BEGIN clause
Work with the EXCEPTION clause
Use explicit cursors
Understand and use nested blocks
Understand the difference between nested blocks and subprograms
English [Auto]
This lesson is going to focus on the exception clause. And this is where we as developers start trapping for errors within our applications. Now a lot of people think errors are a bad thing but they really aren't. As a matter of fact later on in this course I'm going to show you how we can write our APL sequel scripts in such a way where maybe an error is a good thing where we can trap for a specific error and cause our application to divert or to do something else yet still continue to run. And so we need to understand what's happening within the exception clause. So we're going to start off reviewing the different exception types. You need to understand this because like I said before it only makes you a better programmer. We're going to learn how to trap for exceptions. We are going to identify exception details we're then going to create user declared exceptions where we can create our own exceptions and then trap for those as well. And then we're going to talk about exception functions. And then finally we're going to discuss implicit cursor attributes. Now that sounds pretty scary but it's really not that bad. And it's a nice segue into one of our later lessons but it's a very full lesson that we're going to be discussing. So we need to dig in. So what are the different types of exceptions that we can encounter within our Piel sequel code. Like I said before this is very important for us to understand. The first thing that we have is any type of program processing. So as you can see these are errors which occurred during the execution of our program. Now this could be something like a divide by zero or there's no data. Maybe we have a case statement but we'd never put that else in. And so it never triggered any any of the options within that case. These are all exceptions that can be triggered within our appeal sequel code. The other option we have is an internal Oracle error. So this is an error that a that comes from the Oracle environment. Now these are a little bit more difficult to work with but the exception clause will stop this as well. And then finally we have our user declared. Now basically here's what we're going to discuss it later on. But a user declared exception is one where we know what the error code is and we want to give that area code a name that we can use within our application. So it's a very simple process is really not that difficult to do. And what it also does for us is it allows us to test for specific errors and I'm going to show you how we do that it's pretty cool. Now the exception process there are some rules that you need to understand and if you don't understand these make sure you watch this again it's really not that bad. But I want you to understand this part first and foremost. Virtually anything that can be done within the begin clause can be done within the exception clause because if you think about it the begin clause is where we actually start writing our code. Well we can do the exact same thing within the exception clause. Now there's a little thing that we do where we where we test the error that occurred but we can write code in there we can put if statement we can put loops we can do whatever we want to within the exception statement. And that is a very important point that you must understand because we can encounter an error and then we might. Like I said before an era can be something that tells us a little bit more about what we're doing and then we can process something differently in the event that an exception does occur. Pretty cool once control has been passed to the exception clause. It can never go back to the begin clause. So this is a very important thing to remember whereas other programming languages will allow you to go to an exception area and then pop back out peel sequel doesn't do this. Once you enter exception you are there until the process is complete. So just keep that in mind. And then finally when an exception is detected control is passed to. The exception clause if there is no exception clause that exception or that error will bubble up. So later on we're going to talk about Nestea nesting statements where we can have a begin clause inside of another beginning clause.
Рекомендации по теме
join shbcf.ru