PL/SQL Exception handling
Exception handling when the input number is not in the case
declare-- definition v_ename emp.ename%type;begin--Selectfromwhere Empno = &gno;dbms.output.put_line (' name:'| | v_ename); Exceptionwhen no_data_found thendbms_output.put_line (' no number! ' ); end;
--Custom exceptions
Create or Replace procedure Ex_test (spno number) is-- definition exception myexcep exception;begin--set,where empno = Spno; --sql%NotFound This is to indicate no update--raise MYEXCEP trigger Myexcepif sql%if ; Exceptionwhen myexcep thendbms_output.put_line (' no update'); end ;
Oracle View
A view is a virtual table whose contents are defined by a query, as with a real table, and the view contains a series of column and row data with names, but the view is not
The database exists as a stored set of data values, and row and column data is derived from the tables referenced by the query that defines the view, and is generated dynamically when the view is referenced.
The table requires disk space, and the view does not require
View Cannot add index
Use views to simplify complex queries
as Select from where sal<; Use view selectfrom asSelect fromwhere emp.deptno = Dept.deptno; Select from Myview2;
Oracle database exception handling and views