Which two statements are true about the handling of internally defined or user-defined PL7SQL exceptions? (Choose two.)
A.
Add exception handlers whenever errors occur.
B.
An exception handler should commit the transaction.
C.
Handle named exceptions whenever possible instead of using when others in exception handlers
D.
Instead of adding exception handlers to your PL/SQL block, check for errors at every point where they may occur.
A & C is the answer. According to Oracle documentation D is wrong: http://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm#i3880
I think A is not correct, in the same link it has mentioned
that”Add exception handlers whenever there is any POSSIBILITY of an error occurring.” so only posibility of error can handle
2.C is answer is “Instead of checking for an error at every point it might occur, just add an exception handler to your PL/SQL block. If the exception is ever raised in that block (or any sub-block), you can be sure it will be handled.”
I think c and d is correct…..waiting for your clarification
http://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm#i3880
Guidelines for Avoiding and Handling PL/SQL Errors and Exceptions
Because reliability is crucial for database programs, use both error checking and exception handling to ensure your program can handle all possibilities:
Add exception handlers whenever there is any possibility of an error occurring. Errors are especially likely during arithmetic calculations, string manipulation, and database operations. Errors could also occur at other times, for example if a hardware failure with disk storage or memory causes a problem that has nothing to do with your code; but your code still needs to take corrective action.
Add error-checking code whenever you can predict that an error might occur if your code gets bad input data. Expect that at some time, your code will be passed incorrect or null parameters, that your queries will return no rows or more rows than you expect.
Make your programs robust enough to work even if the database is not in the state you expect. For example, perhaps a table you query will have columns added or deleted, or their types changed. You can avoid such problems by declaring individual variables with %TYPE qualifiers, and declaring records to hold query results with %ROWTYPE qualifiers.
Handle named exceptions whenever possible, instead of using WHEN OTHERS in exception handlers. Learn the names and causes of the predefined exceptions. If your database operations might cause particular ORA- errors, associate names with these errors so you can write handlers for them. (You will learn how to do that later in this chapter.)
Test your code with different combinations of bad data to see what potential errors arise.
Write out debugging information in your exception handlers. You might store such information in a separate table. If so, do it by making a call to a procedure declared with the PRAGMA AUTONOMOUS_TRANSACTION, so that you can commit your debugging information, even if you roll back the work that the main procedure was doing.
Carefully consider whether each exception handler should commit the transaction, roll it back, or let it continue. Remember, no matter how severe the error is, you want to leave the database in a consistent state and avoid storing any bad data.
B) is not correct. “can” but not “should”.
Carefully consider whether each exception handler should commit the transaction, roll it back, or let it continue. Remember, no matter how severe the error is, you want to leave the database in a consistent state and avoid storing any bad data.
D) is not correct.
From Oracle:
Instead of checking for an error at every point it might occur, just add an exception handler to your PL/SQL block. If the exception is ever raised in that block (or any sub-block), you can be sure it will be handled.
‘A’ and ‘C’
C,D
correct answer : A,C
why D is wrong??
because he is change the statement meaning :
instead of adding exception , check all the code ….wrong
instead of check all the code , adding exception …..right , as programmer
thanks for all
Read thorougly:
http://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm#i3880
Excerpt:
Instead of checking for an error at every point it might occur, just add an exception handler to your PL/SQL block. I
A, C
http://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm#i3880
A, C.
The answer is A & C.
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/errors.htm#BCFEBJBF
Hi all!
I’m going to take this test this week. Can somebody who has taken the test confirm that most, if not all, of the questions will be from these 78 questions?
Thank you.
hi did u completed your exam
a&c
Confirm: A and C are the correct answer.
The following you can read extract of oracle guide:
Add exception handlers whenever there is any possibility of an error occurring. Errors are especially likely during arithmetic calculations, string manipulation, and database operations. Errors could also occur at other times, for example if a hardware failure with disk storage or memory causes a problem that has nothing to do with your code; but your code still needs to take corrective action.
Handle named exceptions whenever possible, instead of using WHEN OTHERS in exception handlers. Learn the names and causes of the predefined exceptions. If your database operations might cause particular ORA- errors, associate names with these errors so you can write handlers for them. (You will learn how to do that later in this chapter.)
Link: (https://docs.oracle.com/cd/B13789_01/appdev.101/b10807/07_errs.htm)
Best Regards,
Giuseppe.
ac