Trapping Oracle Server Exceptions $ach is worth % points " $nter and r&n the 'ollowing PL/SQL PL/SQL bloc(" Loo( at the o&tp&t and answer the 'ollowing 'ollowing )&estions* D$CLA+$ #,n& #,n&mb mber er -. -.$+ $+11!23 !23 *4 005 005 #,region,id w',world,regions"region,id678P$5 #,region,name w',world,regions"region,name678P$5 $9:S$L$C7 region,id! region,name :-7O #,region,id! #,region,name ;+O w',world,regions <=$+$ region,id 4 5 DS,O.7P.7"P.7,L:-$1>+egion* DS,O.7P.7"P.7,L:-$1>+egion* > ?? #,region,id ?? > is* > ?? #,region,name35 #,n&mber *4 #,n&mber / 05 $-D5 A"
DECLARE v_num number ber NUMBE UMBER R(6,2 (6,2)) := := 100 100;; v_regin_i! "#_"r$!_regin%®in_i!'*E; "#_"r$!_regin%& regin_i!'*E; v_regin_n+me "#_"r$!_regin%®in_n+me'*E; BE-N .ELEC regin_i!, regin_n+me -N/ v_regin_i!, v_regin_n+me R/M "#_"r$!_regin% ERE regin_i! = 1; DBM._/U*U&*U_L-NE(3Regin: 3 44 v_regin_i! 44 3 i%: 3 44 v_regin_n+me); v_number := v_number 5 0; e7e89in EN N/_DA N/_DAA_/UND EN DBM._/U*U&*U_L-NE (3n !+9+3); END;
Oracle Academy
1 Database Programming with PL/SQL Copyright © 200! Oracle" All rights reser#ed"
2" odi'y the bloc( again to change the <=$+$ cla&se to region,id 4 2B" +er&n the bloc(" -ow what happens and why@
Divi!e! b er :n Application $press modi'y the bloc( again to handle the latest eception and rer&n yo&r code" Paste the modi'ied code here D$CLA+$ #,n&mber -.$+1!23 *4 005 #,region,id w',world,regions"region,id678P$5 #,region,name w',world,regions"region,name678P$5 $9:S$L$C7 region,id! region,name :-7O #,region,id! #,region,name ;+O w',world,regions <=$+$ region,id 4 2B5 DS,O.7P.7"P.7,L:-$1>+egion* > ?? #,region,id ?? > is* > ?? #,region,name35 #,n&mber *4 #,n&mber / 05 eception <=$- ero,di#ide 7=$DS,O.7P.7"P.7,L:-$ 1>no data>35 $-D5
%" $nter and r&n the 'ollowing PL/SQL bloc(" Loo( at the o&tp&t and answer the 'ollowing )&estions* D$CLA+$ C.+SO+ regions,c&rs :S S$L$C7 E ;+O w',world,regions <=$+$ region,id F 20 O+D$+ 8 region,id5 regions,rec regions,c&rs6+O<78P$5 #,co&nt -.$+135 $9:LOOP ;$7C= regions,c&rs :-7O regions,rec5 $G:7 <=$- regions,c&rs 6-O7;O.-D5 DS,O.7P.7"P.7,L:-$1>+egion* >?? regions,rec"region,id ?? > -ame* > ?? regions,rec"region,name35 $-D LOOP5 CLOS$ regions,c&rs5 S$L$C7 CO.-71E3 :-7O #,co&nt ;+O w',world,regions <=$+$ region,id 4 5
DS,O.7P.7"P.7,L:-$1>7he n&mber o' regions is* > ?? #,co&nt35 $-D5 A"
DECLARE CUR./R regin%_7ur% -. .ELEC < R/M "#_"r$!_regin% ERE regin_i! 20 /RDER B regin_i!; regin%_re7 regin%_7ur%'R/*E; v_7un9 NUMBER(6); BE-N L//* EC regin%_7ur% -N/ regin%_re7; E>- EN regin%_7ur% 'N//UND; DBM._/U*U&*U_L-NE(3Regin: 344 regin%_re7®in_i! 44 3 N+me: 3 44 regin%_re7®in_n+me); END L//*; CL/.E regin%_7ur%; .ELEC C/UN(<) -N/ v_7un9 R/M "#_"r$!_regin% ERE regin_i! = 1; DBM._/U*U&*U_L-NE(3?e number # regin% i%: 3 44 v_7un9); e7e89in EN -N@AL-D_CUR./R EN DBM._/U*U&*U_L-NE (3inv+$i! 7ur%r3); END;
H" $nter and r&n the 'ollowing PL/SQL bloc(" Loo( at the o&tp&t and answer the 'ollowing )&estions*
D$CLA+$ $9::-S$+7 :-7O w',lang&ages1lang&age,id! lang&age,name3 IAL.$S1J0! n&ll35 $-D5 A"
" :n Application $press add a non,prede'ined eception handler to trap the O+A0H00 eception" -ame yo&r eception e,n&ll,not,allowed" +er&n the code and obser#e the res<s" Paste the modi'ied code here D$CLA+$ e,n&ll,not,allowed eception5 P+A9A $GC$P7:O-,:-:7 1e,n&ll,not,allowed! 0H0035 $9::-S$+7 :-7O w',lang&ages1lang&age,id! lang&age,name3 IAL.$S1J0! n&ll35 eception when e,n&ll,not,allowed then DS,O.7P.7"P.7,L:-$1>:-S$+7 ;A:L$D>35 $-D5