Which two statements are true about PL/SQL exception propagation? (Choose two.)
A.
The exception reproduces Itself In successive enclosing blocks until a handler is found.
B.
Exception- can propagate across the remote subprograms that are called through database
links.
C.
If you declare a local exception in a subblock and a global exception in the outer block, the local
declaration overrides the global exception.
D.
If you declare a local exception in a subblock and a global exception in the outer block, the
global declaration overrides the local exception.
A,C
D is incorrect it is obvious
B incorrect:
Exceptions cannot propagate across remote subprogram invocations. Therefore, a PL/SQL block cannot handle an exception raised by a remote subprogram.
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/errors.htm#LNPLS844
A,C
a,c
AC
Propagation – The way in which an exception is passed back through enclosing blocks
until it is handled or is resolved to be an unhandled exception.
If there is an enclosing block for the current block, the exception is passed on to the block and it becomes the current block. If a handler for the raised exception is not found, the process repeats.
If there is no enclosing block for the current block, an unhandled exception error is passed back to the host environment.
Exceptions cannot propagate across remote subprogram invocations.
Local declaration overrides the global declaration.
AC
Oracle Function:
CREATE OR REPLACE
FUNCTION ERROR_TEST(xxxx IN VARCHAR2) RETURN VARCHAR2 AS
ss NUMBER;
BEGIN
ss:=1/0;———————————————Exception Unhandled..
RETURN xxxx;
END ERROR_TEST;
Java Class
package info.Cap.ConnectionData;
import java.sql.Statement;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
public class ExtractEmp {
public ArrayList ExtractData(){
try {
Connection conn=ConnectionClass.connecta();
if (conn != null && !conn.isClosed()) {
Statement stmt = null;
String query = “select employee_id, error_test(first_name) from employees order by employee_id”;
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);
/*while (rs.next()) {
int empid = rs.getInt(“employee_id”);
String fname = rs.getString(“first_name”);
System.out.println(empid +’\t’+ fname);
}*/
ArrayList list = new ArrayList();
while (rs.next()) {
Container wb=new Container();
wb.setEmpid(rs.getInt(“employee_id”));
wb.setName(rs.getString(“first_name”));
list.add(wb);
}
stmt.close();
conn.close();
System.out.println(“Connection Closed!!”);
return list;
}} catch (SQLException ex) {
ex.printStackTrace();
}
return null;
}
}
main Class:
package info.Cap.ConnectionData;
import java.util.ArrayList;
public class AllTest {
public static void main(String args[]) {
// TODO Auto-generated method stub
ExtractEmp a1= new ExtractEmp();
ArrayList list = new ArrayList();
list =a1.ExtractData();
for (Container c : list){
System.out.println(c.getEmpid()+ “\t” +c.getName());
}
}
}
Result:
Connected with Oracle
java.sql.SQLDataException: ORA-01476: divisor is equal to zero
ORA-06512: at “HR.ERROR_TEST”, line 4