Test:Semester1FinalExam 1. You Youh hav ave ecr crea eate ted da afu func ncti tion onn nam amed edN NEW EWFU FUNC NC. .Yo You uno now wch chan ange ges som ome eof oft the hef f unctioncode,andtrytorecreatethefunctionbyexecuting: CREATEORREPLACEFUNCTIONnewfunc....; Whathappens? MarkforReview (1)Points Thecommandfailsbecausethefunctionalreadyexists. Thefunctionisautomaticallydroppedandthenrecreated.(*) Thecommandfailsbecauseyoushouldexecute: Thecommandfailsbeca useyoushouldexecute:CREATEANDREPLACE....; CREATEANDREPLACE....; AsecondfunctionnamedNEWFUNC_2iscreated. Thefunctionisdroppedbutnotrecreated.
Correct 2. Afu Afunc ncti tion onn nam amed edM MYF YFUN UNC Cha has sbe been enc cre reat ated ed. .Th This isf fun unct ctio ion n acceptsoneINparameterofdatatypeVARCHAR2 acceptsoneINparamet erofdatatypeVARCHAR2andreturnsaNUMBER.You andreturnsaNUMBER.Youwantto wantto invokethefunctionwithinthefollowinganonymousblock: DECLARE v_var1NUMBER(6,2); BEGIN --LineA END; WhatcouldbecodedatLiineA? MarkforReview (1)Points myfunc('Crocodile'):=v_var1; myfunc(v_var1):='Crocodile'; myfunc(v_var1,'Crocodile'); v_var1:=myfunc('Crocodile');(*) myfunc('Crocodile',v_var1);
Correct 3. CREATEFUNCTIONADD_EM (aNUMBER:=1, bNUMBER:=2) RETURNNUMBER ISBEGIN RETURN(a+b); ENDADD_EM;
Co n s i d e r t h e f o l l o w i ng f u n c t i o n :
WhichoneofthefollowingblockswillNOTworkcorrectly? MarkforReview (1)Points DECLARE xNUMBER; BEGIN x:=add_em(b=4); END; (*)
DECLARE xNUMBER; BEGIN x:=add_em(4); END; DECLARE xNUMBER; BEGIN x:=add_em(4,5); END; DECLARE xNUMBER; BEGIN x:=add_em; END; Noneofthemwillwork.
Correct 4. You Yout try ryt to ocr crea eate tea af fun unct ctio ion nna name med dMY MYFU FUNC NC. .Th The efu func ncti tion on doesnotcompilecorrectlybecausethereareerrorsinyourcode.Whic doesnotcompilecorrectlybecausethereare errorsinyourcode.WhichDiction hDiction aryvi aryview ewcan canyo youq uquer ueryt ytos osee eethe theer error rors? s? Markf Markfor orRev Review iew (1)Points
USER_SOURCE USER_ERRORS(*) USER_OBJECTS USER_DEPENDENCIES USER_COMPILES
Correct 5. ure urean and da afu func ncti tion on? ? (1)Points
Whi Which cho of fth the efo foll llow owin ing gis isa ad dif iffe fere renc nce ebe betw twee een na apr proc oced ed Mark Markf for orR Rev evie iew w
AprocedurecanincludeDMLstatements,butafunctioncannot. AfunctionmusthaveatleastoneINparameter,whileparametersareop AfunctionmusthaveatleastoneINparameter ,whileparametersareopt t ionalforaprocedure. AprocedurecanreturnaBOOLEANdatatype,whi Aprocedurecanreturn aBOOLEANdatatype,whileafunctioncannot. leafunctioncannot. AfunctioncanbeusedinsideaSQLstatement, Afunctioncanbeused insideaSQLstatement,whileaprocedurecannot whileaprocedurecannot. . (*) AprocedurecanincludeanEXCEPTIONsection, Aprocedurecaninclud eanEXCEPTIONsection,whileafunctioncannot. whileafunctioncannot.
Incorrect.RefertoSection9Lesson1. 6. Whi Which cho of fth the efo foll llow owin ing gbe best std des escr crib ibes esa as sto tore red dfu func ncti tion on ? Ma r k f o r R e v i ew (1)Points Asubprogramthatmustreturnexactlyonevalue.(*) AsubprogramthatmusthaveatleastoneINparameter. AsubprogramthathasnoOUTorINOUTparameters.
Asubprogramthatexecutesautomaticallywhen Asubprogramthatexec utesautomaticallywhenaDMLstatementisexecut aDMLstatementisexecute e donatable. Asubprogramwhichinvokesanothersubprogram.
Correct 7. ctio ctions ns? ?(C (Cho hoos ose e3) 3) (1)Points
Whi Which cho of fth the efo foll llow owin ing gis isa ab ben enef efit ito of fus user er-d -def efin ined edf fun un Mark Markf for orR Rev evie iew w (Chooseallcorrectanswers)
Theycanaddbusinessrulestothedatabasean Theycanaddbusiness rulestothedatabaseandcanbereusedmanytime dcanbereusedmanytimes s .(*) TheycanbeusedinaWHEREclausetofilterd Theycanbeusedina WHEREclausetofilterdataandtherebyincrease ataandtherebyincreasee e fficiency.(*) Theycandothesamejobasbuilt-insystemfu Theycandothesamej obasbuilt-insystemfunctionssuchasUPPERand nctionssuchasUPPERand ROUND. TheycanoftenbeusedinsideSQLstatements.(*)
Correct 8. Why Whywi will llt the hef fol ollo lowi wing ngs sta tate teme ment ntf fai ail? l? SELECTemployee_id,tax(p_value=>salary) FROMemployees; MarkforReview (1)Points User-definedfunctionsarenotallowedintheSELECTclause Namenotationisnotallowed(*) Thedatatypeforthetaxvariabledoesnotma Thedatatypeforthe taxvariabledoesnotmatchthedatatypeforsal tchthedatatypeforsala a ry Thestatementwillexecuteandnotfail
Correct 9. The Thef fun unct ctio ion nav avg_ g_an ann_ n_sa sal lre retu turn rns sth the eav aver erag age ean annu nual als sal al aryforaparticulardepartment.Theexampleb aryforaparticulard epartment.Theexamplebelowisavaliduseofof elowisavaliduseofofthisfun thisfun ction.TrueorFalse? SELECTfirst_name,last_name FROMemployees WHEREavg_ann_sal(20)>15000; MarkforReview (1)Points True(*) False
Correct 10. 10. Whi Which chD Dat ata aDi Dict ctio iona nary ryv vie iew wca can nbe beu use sed dto tod dis ispl play ayt the hed d etaile etailedc dcode odeof ofa apro proced cedure urein inyo your ursch schema ema? ? Markf Markfor orRev Review iew (1)Points USER_PROCEDURES USER_OBJECTS USER_SOURCE(*) USER_SUBPROGRAMS Noneoftheabove.
Correct 11. Youw Youwant antto tose seet ethe henam names, es,mo modes desan andd ddata ataty types pesof ofth thef eform ormal alpar parame ameter ter soffunctionMY_FUNCinyourschema.Howcan soffunctionMY_FUNC inyourschema.Howcanyoudothis?(Choosetwo) youdothis?(Choosetwo) Markfor Review (1)Points (Chooseallcorrectanswers) QueryUSER_PARAMETERS QueryUSER_SOURCE(*)
QueryUSER_FUNCTIONS SHOWPARAMETERmy_func; DESCRIBEmy_func;(*)
Incorrect.RefertoSection9Lesson4. 12. 12.
Exa Exami mine net the hef fol ollo lowi wing ngc cod ode: e:C CRE REAT ATE EPR PROC OCED EDUR URE Epa pare rent nt
ISBEGIN child1; child2; EXCEPTION WHENNO_DATA_FOUNDTHENNULL; ENDparent; NeitherCHILD1norCHILD2hasanexceptionhandler. WhenPARENTisinvoked,CHILD1raisesaNO_DAT WhenPARENTisinvoked ,CHILD1raisesaNO_DATA_FOUNDexception.Whath A_FOUNDexception.Whathappensne appensne xt? MarkforReview (1)Points PARENThandlestheexception,thenCHILD1continuestoexecute. CHILD1endsabruptly.PARENThandlestheexcep CHILD1endsabruptly. PARENThandlestheexceptionandthenends.CHILD tionandthenends.CHILD2 2 doesnotexecute.(*) CHILD1endsabruptly,PARENThandlestheexcep CHILD1endsabruptly, PARENThandlestheexception,thenCHILD2execute tion,thenCHILD2executes s . CHILD1endsabruptly,PARENTalsoendsabruptl CHILD1endsabruptly, PARENTalsoendsabruptlyandreturnsanunhandle yandreturnsanunhandled d exception. PARENTdoesnotcompilebecauseyoucannotuse PARENTdoesnotcompil ebecauseyoucannotuseNULL;inanexceptionha NULL;inanexceptionhan n dler.
Correct 13. 13. User UserR REY EYHA HAN Ncr crea eate tes sth the efo foll llow owin ing gpr proc oced edur ure: e: CREATEPROCEDUREproc1AUTHIDCURRENT_USER IS v_countNUMBER; BEGIN SELECTCOUNT(*)INTOv_count FROMtom.employees; END;
UserBILLwantstoexecutethisprocedure.Wha UserBILLwantstoexe cutethisprocedure.WhatprivilegeswillBILLne tprivilegeswillBILLneed? ed? MarkforReview (1)Points EXECUTEonREYHAN.PROC1andSELECTonTOM.EMPLOYEES(*) EXECUTEonREYHAN.PROC1 SELECTonTOM.EMPLOYEES BILLneedsnoprivileges Noneoftheabove.TheprocedurewillfailtocompilebecauseREYHANdo Noneoftheabove.Theprocedurewillfailto compilebecauseREYHANdoe e snothaveSELECTprivilegeonTOM.EMPLOYEES.
Correct 14. 14. Whe When nmu must stA AUT UTHI HID DCU CURR RREN ENT_ T_US USER ERb be ein incl clud uded edi in nan ana aut uton onom om oustr oustrans ansact action ionsu subpr bprogr ogram? am? Markf Markfor orRev Review iew (1)Points WhendeclaringDefiner'srights WhendeclaringInvoker'srights(*) WhenusingCOMMITorROLLBACK WhenusingGRANTonthesubprogram
Correct 15. 15. User UserB BOB OBc cre reat ates esp pro roce cedu dure reM MYP YPRO ROC Cus usin ing gth the ede defa faul ult tDe Defi fi ner'sRights.BOBthenexecutes: GRANTEXECUTEONbob.myprocTOted; WhenTEDinvokesBOB.MYPROC,whoseprivilegesarechecked? MarkforReview (1)Points TED'sprivileges
PUBLIC'sprivileges SYSTEM'sprivileges BOB'sprivileges(*) ORACLE'sprivileges
Correct
Section8 (Answerallquestionsinthissection) 16. 16. Whi Which cho of fth the efo foll llow owin ing gar are ech char arac acte teri rist stic ics sof ofP PL/ L/SQ SQL Lsu su bprograms bprogramsbutn butnotof otofanon anonymous ymousPL/S PL/SQLbl QLblocks? ocks?(Cho (Chooset osethree. hree.) ) MarkforR MarkforReview eview (1)Points (Chooseallcorrectanswers) Cantakeparameters(*) Arestoredinthedatabase(*) CanbeginwiththekeywordDECLARE Arenamed(*) Arecompiledeverytimetheyareexecuted
Correct 17. 17. Ap Apro rogr gram amme mer rwa want nts sto toc cre reat ate ea aPL PL/S /SQL QLp pro roce cedu dure ren nam amed edE E MP_PROC.Whatwillhappenwhenthefollowingcodeisexecuted? CREATEORREPLACEPROCEDUREemp_procIS v_salaryemployees.salary%TYPE; BEGIN SELECTsalaryINTOv_salaryFROMemployees WHEREemployee_id=999; DBMS_OUTPUT.PUT_LINE('Thesalaryis:'||v_salary); END; MarkforReview (1)Points
ThestatementwillraiseaNO_DATA_FOUNDexcep Thestatementwillrai seaNO_DATA_FOUNDexceptionbecauseemployee_id tionbecauseemployee_id9 9 99doesnotexist. Thestatementwillfailbecausethelastline Thestatementwillfai lbecausethelastlineofcodeshouldbeENDemp ofcodeshouldbeENDemp_ _ proc; Thestatementwillfailbecauseyoucannotdec Thestatementwillfai lbecauseyoucannotdeclarevariablessuchasv_ larevariablessuchasv_s s alaryinsideaprocedure. Theprocedurewillbecreatedsuccessfully.(*) Thestatementwillfailbecausetheprocedure Thestatementwillfai lbecausetheproceduredoesnothaveanyparamet doesnothaveanyparamete e rs.
Correct 18. 18. The Thef fol ollo lowi wing nga are ret the hes ste teps psi inv nvol olve ved din inc cre reat atin ing, g,a and ndl l atermodifyingandre-creating,aPL/SQLproce atermodifyingandrecreating,aPL/SQLprocedureinApplicationExpre dureinApplicationExpress.Inwh ss.Inwh atsequenceshouldthesestepsbeperformed? Retrievethesavedcodefrom"SavedSQL"inSQLCommands Executethecodetocreatetheprocedure Executethecodetore-createtheprocedure Clickonthe"Save"buttonandsavetheprocedurecode ModifythecodeintheSQLCommandswindow TypetheprocedurecodeintheSQLCommandswindow MarkforReview (1)Points F,C,A,B,E,D F,B,D,A,E,C(*) E,D,F,C,A,B F,B,D,E,A,C F,B,C,D,E,A
Correct 19. 19. An Anes este ted dsu subp bpro rogr gram amc can ano onl nly ybe bei inv nvok oked edf fro rom mth the ema main ins s ubpr ubprog ogra ram. m.T Tru rue eor orF Fal alse se? ? Mark Markf for orR Rev evie iew w (1)Points
True(*) False
Correct 20. 20. Ap Apro rogr gram amme mer rcr crea eate tes sa aPL PL/S /SQL QLs sub ubpr prog ogra ram mwh whic ich his isc com ompi pi ledandstoredinthedatabase.Twoseparateu ledandstoredinthe database.Twoseparateusersthenexecuteanappl sersthenexecuteanapplicationw icationw hichinvokesthissubprogramfourtimes.Howm hichinvokesthissubp rogramfourtimes.Howmanytimesmustthesubpro anytimesmustthesubprogramber gramber ecomp compil iled ed? ? Mark arkf forR orRev evie iew w (1)Points Twice Fourtimes None(*) Eighttimes Once
Correct 21. Which Whichof ofth thef efoll ollowi owing ngare arech chara aracte cteris ristic ticso sofP fPL/S L/SQL QLsto stored redpr proce ocedur dures? es? (Cho (Choos ose eth thre ree. e.) ) Mark Markf for orR Rev evie iew w (1)Points (Chooseallcorrectanswers) TheyarenamedPL/SQLblocks(*) Theymustreturnexactlyonevaluetothecallingenvironment. Theycanhaveanexceptionsection.(*) TheycanbeinvokedfrominsideaSQLstatement. Theycanacceptparameters.(*)
Correct
22. 22. Sup Suppo pose sey you ous set etu up pa apa para rame mete ter rwi with tha an nex expl plic icit itO OUT UTm mod od e.Whatis e.Whatistrue trueabou abouttha tthatpar tparamete ameter? r? MarkforR MarkforReview eview (1)Points ItmusthaveaDEFAULTvalue. ItcannothaveaDEFAULTvalue.(*) Itactslikeaconstant(itsvaluecannotbec Itactslikeaconstan t(itsvaluecannotbechangedinsidethesubprog hangedinsidethesubprogr r am). ItmustbethesametypeasthematchingINparameter. ItinheritsitstypefromthematchingINparameter.
Correct 23. 23. Sup Suppo pose sey you ous set etu up pa apa para rame mete ter rwi with tha an nex expl plic icit itI IN Nmo mode de .Whatis .Whatistrue trueabout aboutthat thatpara parameter meter? ? MarkforR MarkforReview eview (1)Points ItmusthaveaDEFAULTvalue. ItcannothaveaDEFAULTvalue. Itactslikeaconstant(itsvaluecannotbechangedinsidethesubprog Itactslikeaconstant(itsvaluecannotbec hangedinsidethesubprogr r am).(*) ItmustbethesametypeasthematchingOUTparameter. ItinheritsitstypefromthematchingOUTparameter.
Incorrect.RefertoSection8Lesson3. 24. 24. The Thefo foll llow owin ing gpr proc oced edur ure eha has sbe been enc cre reat ated ed: : CREATEORREPLACEPROCEDUREmyproc (AINNUMBER:=20, BINNUMBER, CINNUMBERDEFAULT30) IS..... Whichofthefollowingwillinvoketheprocedurecorrectly?
MarkforReview (1)Points myproc(40); myproc(10,B=>30,50); myproc(C=>25); Alloftheabove Noneoftheabove(*)
Correct 25. 25. Pro Proce cedu dure reS SOM OMEP EPRO ROC Cha has sfi five vep par aram amet eter ers sna name med dA, A,B B, ,C, C,D D ,Einthatorder.Theprocedurewascalledasfollows: SOMEPROC(10,20,D=>50); HowwasparameterBreferenced? MarkforReview (1)Points Positional(*) Named Acombinationofpositionallyandnamed Acombinationofnamedanddefaulted Defaulted
Correct 26. 26. You Youha have vec cre reat ated edt the hef fol ollo lowi wing ngp pro roce cedu dure re: : CREATEORREPLACEPROCEDUREdouble_it (p_paramINOUTNUMBER) IS BEGIN p_param:=p_param*2; END;
Whichofthefollowinganonymousblocksinvoke Whichofthefollowing anonymousblocksinvokesthisproceduresuccessf sthisproceduresuccessfully? ully? MarkforReview (1)Points BEGIN EXECUTEdouble_it(20); END; BEGIN SELECTdouble_it(20) FROMDUAL; END; DECLARE v_resultNUMBER(6); BEGIN v_result:=double_it(20); END; DECLARE v_resultNUMBER(6):=20; BEGIN double_it(v_result); END;(*) BEGIN double_it(20); END;
Correct
param aramet eter er. . (1)Points
27. 27. Ap Apro roce cedu dure rew wil ill lex exec ecut ute efa fast ster eri if fit ith has asa at tle leas ast ton one e Mark arkf forR orRev evie iew w
True False(*)
Correct 28. 28. Whi Which cho of fth the efo foll llow owin ing gbe best std des escr crib ibes esh how owa an nIN INp par aram amet et eraffectsaprocedure? MarkforReview eraffectsaprocedure? (1)Points
Itdescribestheorderinwhichtheprocedure' Itdescribestheorder inwhichtheprocedure'sstatementsshouldbeex sstatementsshouldbeexe e cuted. Itdescribeswhichpartsoftheprocedure'sco Itdescribeswhichpar tsoftheprocedure'scodeareoptionalorcondit deareoptionalorconditi i onal. Itmakestheprocedureexecutefaster. Itpassesavalueintotheprocedurewhenthe Itpassesavalueinto theprocedurewhentheprocedureisinvoked.(*) procedureisinvoked.(*) Itallowscomplexcalculationstobeexecuted Itallowscomplexcalc ulationstobeexecutedinsidetheprocedure. insidetheprocedure.
Correct 29. 29. edure durep par aram amet eter er? ? (1)Points
Whi Which cho of fth the efo foll llow owin ing gis isN NOT OTc cor orre rect ctc cod odin ing gfo for ra apr proc oc Mark Markf for orR Rev evie iew w
(p_paramINVARCHAR2) (p_paramVARCHAR2) (p_paramVARCHAR2(50))(*) (p_paramemployees.last_name%TYPE) (p_paramINOUTVARCHAR2)
Correct 30. Exa Exami mine net the hef fol ollo lowi wing ngp pro roce cedu dure re: : CREATEORREPLACEPROCEDUREsmallproc (p_paramINNUMBER) IS BEGIN.... Theprocedureisinvokedby: DECLARE v_paramNUMBER:=20; BEGIN smallproc(v_param); END;
Whichofthefollowingstatementsistrue? MarkforReview (1)Points p_paramisaparameterandv_paramisanargument p_paramisaformalparameterand20isanactualparameter p_paramisaformalparameterandv_paramisa p_paramisaformalpa rameterandv_paramisanactualparameter(*) nactualparameter(*) p_paramandv_paramarebothformalparameters p_paramandv_paramar ebothformalparameters,while20isanactualp ,while20isanactualpa a rameter p_paramisanactualparameterandv_paramis p_paramisanactualp arameterandv_paramisaformalparameter aformalparameter
Correct 31. AnI AnIND NDEX EXB BY YT TABLE ABLEm mus ust tha have vea ap pri rima mary ryk key ey (1)Points
Mark Markf for orR Rev evie iew w
True(*) False
Correct 32. 32. You Youc can ans sto tore rea aw who hole ler rec ecor ord din ina as sin ingl gle eva vari riab able leu usi sing ng %ROWTYPEorbycreatingyoruownrecordstructureasatypeandthend %ROWTYPEorbycreatingyoruownrecordstruc tureasatypeandthendeclaring eclaring ava avari riab able leo of fth that att typ ype. e. Mark Markf for orR Rev evie iew w (1)Points True(*) False
Incorrect.RefertoSection6Lesson1.
Section7 (Answerallquestionsinthissection)
33. 33. Dep Depar artm tmen entt-id id9 99 9do does esn not ote exi xist st. .Wh What atw wil ill lbe bed dis ispl play ayed ed whenthefollowingcodeisexecuted? DECLARE v_deptnamedepartments.department_name%TYPE; BEGIN SELECTdepartment_nameINTOv_deptname FROMdepartmentsWHEREdepartment_id=99; EXCEPTION WHENNO_DATA_FOUNDTHEN RAISE_APPLICATION_ERROR(-20201,'Departm RAISE_APPLICATI ON_ERROR(-20201,'Departmentdoesnotexist'); entdoesnotexist'); END; MarkforReview (1)Points ORA-01403:NoDataFoundORA-20201:Departmentdoesnotexist ORA-01403:NoDataFound ORA-20201:Departmentdoesnotexist(*) Noneoftheabove
Correct 34. 34. defineder definederrorm rormessag essage? e? (1)Points
Whi Which cho of fth the efo foll llow owin ing gwi will lls suc ucce cess ssfu full lly yre retu turn rna au use serrMarkforR MarkforReview eview
RAISE_APPLICATION_ERROR('ErrorRaised',-22001); RAISE_APPLICATION_ERROR(-20257,'Errorraised');(*) RAISE_APPLICATION_ERROR(-22001,'ErrorRaised'); RAISE_APPLICATION_ERROR('ErrorRaised',-20257);
Correct 35. 35. Au Ause serr-de defi fine ned dex exce cept ptio ion nca can nbe ber rai aise sed: d: A.Inthedeclarationsection B.Intheexecutablesection C.Intheexceptionsection MarkforReview (1)Points
B C AandB BandC(*) AandC
Correct 36. 36. Use Userr-de defi fine ned dex exce cept ptio ions nsm mus ust tbe bed dec ecla lare red dex expl plic icit itly lyb by y theprogrammer,butthenareraisedautomatica theprogrammer,butth enareraisedautomaticallybytheOracleServer. llybytheOracleServer.Trueor Trueor False? False? MarkforR MarkforReview eview (1)Points True False(*)
Incorrect.RefertoSection7Lesson3. 37. 37. Wha What twi will llh hap appe pen nwh when ent the hef fol ollo lowi wing ngc cod ode eis ise exe xecu cute ted? d? DECLARE e_outer_excepEXCEPTION; BEGIN DECLARE e_inner_excepEXCEPTION; BEGIN RAISEe_outer_excep; END; EXCEPTION WHENe_outer_excepTHEN DBMS_OUTPUT.PUT_LINE('Outerraised'); WHENe_inner_excepTHEN DBMS_OUTPUT.PUT_LINE('Innerraised'); END; MarkforReview (1)Points Thecodewillfailtocompilebecausee_inner_ Thecodewillfailto compilebecausee_inner_excepcannotbereference excepcannotbereferenced d intheouterblock.(*)
Thecodewillpropagatethee_outer_excepback Thecodewillpropagat ethee_outer_excepbacktothecallingenvironme tothecallingenvironmen n t. Thecodewillexecutesuccessfullyand'Outer Thecodewillexecute successfullyand'OuterRaised'willbedisplayed Raised'willbedisplayed. . Thecodewillfailtocompilebecausee_inner_excepwasdeclaredbutne Thecodewillfailtocompilebecausee_inner_ excepwasdeclaredbutnev v erRAISEd.
Correct 38. 38. Usi Using ngt two won nes este ted dbl bloc ocks ks, ,a aTO TOO_ O_MA MANY NY_R _ROW OWS Sex exce cept ptio ion nis isr r aisedwithintheinnerblock.Whichofthefol aisedwithintheinner block.Whichofthefollowingexceptionhandlers lowingexceptionhandlerswillsuc willsuc cessfullyhandletheexception? cessfullyhandlethee xception? MarkforReview (1)Points WHENTOO_MANY_ROWSintheinnerblock WHENTOO_MANY_ROWSineitherblock WHENOTHERSineitherblock WHENOTHERSintheinnerblock Alloftheabove(*)
Correct 39. 39. Exc Excep epti tion ons sde decl clar ared edi in na abl bloc ock kar are eco cons nsid ider ered edl loc ocal alt to o thatblock thatblock,and ,andglob globalto altoall allitss itssub-bl ub-blocks. ocks.True TrueorF orFalse? alse? MarkforR MarkforReview eview (1)Points True(*) False
Correct 40. 40. The There rea are ren no oem empl ploy oyee ees sin ind dep epar artm tmen ent t75 75. .Wh What atw wil ill lbe bed d isplayedwhenthiscodeisexecuted? DECLARE v_last_nameemployees.last_name%TYPE; BEGIN
DBMS_OUTPUT.PUT_LINE('A'); BEGIN SELECTlast_nameINTOv_last_name FROMemployeesWHEREdepartment_id=75; DBMS_OUTPUT.PUT_LINE('B'); END; DBMS_OUTPUT.PUT_LINE('C'); EXCEPTION WHENOTHERSTHEN DBMS_OUTPUT.PUT_LINE('D'); END; MarkforReview (1)Points A C D A D (*)
A A B D Noneoftheabove
Correct 41. Exami Examine nethe thefo follo llowin wingc gcode odefr fragm agment ent.A .AtL tLine ineA, A,yo youw uwant antto tora raise isean anex ex ceptionifthefetchedsalaryvalueisgreater ceptionifthefetched salaryvalueisgreaterthan30000.Howcanyou than30000.Howcanyoudothis? dothis? DECLARE v_salaryemployees.salary%TYPE; BEGIN SELECTsalaryINTOv_salaryFROMemployees WHEREemployee_id=100; IFv_salary>30000THEN --LineA ENDIF; ... MarkforReview (1)Points TestforWHENVALUE_TOO_HIGHintheexceptionsection. UseRAISE_APPLICATION_ERRORtoraiseanexcept UseRAISE_APPLICATION_ ERRORtoraiseanexceptionexplicitly.(*) ionexplicitly.(*)
TestforWHENOTHERSintheexceptionsection, TestforWHENOTHERSi ntheexceptionsection,becauseWHENOTHERStrap becauseWHENOTHERStraps s allexceptions. DefineanEXCEPTIONvariableandassociateitwithanOracleServererr DefineanEXCEPTIONvariableandassociateit withanOracleServererro o rnumberusingPRAGMAEXCEPTION_INIT.
Correct 42. 42. Exa Exami mine net the hef fol ollo lowi wiin ing gco code de. .Wh Whic ich hex exce cept ptio ion nha hand ndle lers rsw w ouldsuccessfullytraptheexceptionwhichwil ouldsuccessfullytrap theexceptionwhichwillberaisedwhenthiscod lberaisedwhenthiscodeisexec eisexec uted?(Choosetwo.) DECLARE CURSORemp_cursISSELECT*FROMemployees; v_emp_recemp_curs%ROWTYPE; BEGIN FETCHemp_cursINTOv_emp_rec; OPENemp_curs; CLOSEemp_curs; EXCEPTION... END; MarkforReview (1)Points (Chooseallcorrectanswers) WHENCURSOR_NOT_OPEN WHENINVALID_CURSOR(*) WHENOTHERS(*) WHENNO_DATA_FOUND WHENINVALID_FETCH
Incorrect.RefertoSection7Lesson2. 43. 43. An Anat atte temp mpt tto toi ins nser ert ta anu null llv val alue uei int nto oa aNO NOT TNU NULL LLt tab able le columnraisesanORA-01400exception.Howcanyoucodeanexceptionha columnraisesanORA-01400exception.Howcan youcodeanexceptionhandlerto ndlerto trapt trapthis hisex excep ceptio tion? n? Markf Markfor orRev Review iew (1)Points TestforWHENORA-1400intheexceptionsection. Declareavariablee_null_excepoftypeEXCEPT Declareavariablee_n ull_excepoftypeEXCEPTION,associateitwithOR ION,associateitwithORA A
-01400usingaPRAGMAdirective,andtestforWHENe_null_excepinthe -01400usingaPRAGMAdirective,andtestfor WHENe_null_excepintheexception exception section.(*) Declareavariablee_null_excepoftypeVARCHA Declareavariablee_n ull_excepoftypeVARCHAR2,associateitwithORA R2,associateitwithORA01400usingaPRAGMAdirective,andtestforWHENe_null_excepinthee 01400usingaPRAGMAdirective,andtestforW HENe_null_excepintheexception xception section. Declareavariableasfollows:e_null_excepEX Declareavariableas follows:e_null_excepEXCEPTION:=-01400;Thent CEPTION:=-01400;Thente e stforWHENe_null_excepintheexceptionsection.
Correct 44. 44. Whi Which chk kin inds dso of fex exce cept ptio ions nsa are rer rai aise sed dim impl plic icit itly ly( (i. i.e. e., , automatica automatically)? lly)?(Cho (Chooset osetwo.) wo.) MarkforR MarkforReview eview (1)Points (Chooseallcorrectanswers) PredefinedOracleServererrorssuchasNO_DATA_FOUND(*) User-definederrors Allerrors Non-predefinedOracleServererrorssuchasORA-01400(*)
Correct 45. 45. Whi Which cho of fth thes ese eex exce cept ptio ions nsw wou ould ldn nee eed dto tob be era rais ised ede exp xpli li citlybythePL/SQLprogrammer? citlybythePL/SQLpr ogrammer? MarkforReview (1)Points OTHERS ASELECTstatementreturnsmorethanonerow. Acheckconstraintisviolated. ASQLUPDATEstatementdoesnotupdateanyrows.(*) ArowisFETCHedfromacursorwhilethecursorisclosed.
Correct 46. 46. An Anat atte temp mpt tto tou upd pdat ate ean ane emp mplo loye yee' e's ssa sala lary ryt to oa ane nega gati tive ve valuewillviolateacheckconstraintandraiseanORA-02290exception valuewillviolateacheckconstraintandrai seanORA-02290exception.Whicho .Whicho fthefollowingisacorrectdefinitionofah fthefollowingisac orrectdefinitionofahandlerforthisexception andlerforthisexception? ? MarkforReview (1)Points DECLARE e_sal_excepEXCEPTION; PRAGMAEXCEPTION_INIT(-02290,e_sal_excep); DECLARE PRAGMAEXCEPTION_INIT(e_sal_excep,-02290); e_sal_excepEXCEPTION; DECLARE e_sal_excepEXCEPTION; PRAGMAEXCEPTION_INIT(e_sal_excep,-02290); (*)
DECLARE e_sal_excepEXCEPTION; PRAGMA_EXCEPTION_INIT(e_sal_exception,-02290); DECLARE e_sal_excepEXCEPTION; PRAGMAEXCEPTION_INIT(e_sal_excep,02290);
Correct 47. 47. The Thef fol ollo lowi wing ngE EXC XCEP EPTI TION ONs sec ecti tion oni is sco cons nstr truc ucte ted dco corr rrec ectl tl y.TrueorFalse? EXCEPTION WHENNO_DATA_FOUNDORTOO_MANY_ROWS THENstatement_1; statement_2; WHENOTHERS THENstatement_3; END; MarkforReview (1)Points True(*) False
Correct 48. 48. Whi Which cho of fth thes ese eex exce cept ptio ions nsc can anb be eha hand ndle led dby bya an nEX EXCE CEPT PTIO IO Nsect Nsection ionin ina aPL/ PL/SQL SQLbl block ock? ? Markf Markfor orRev Review iew (1)Points ASELECTstatementreturnsnorows ASELECTstatementreturnsmorethanonerow Anyotherkindofexceptionthatcanoccurwithintheblock Alloftheabove(*) Noneoftheabove
Correct 49. 49. Whi Which cho of fth the efo foll llow owin ing gis isN NOT OTa an nad adva vant ntag age eof ofi inc nclu ludi ding ng an anex exce cept ptio ion nha hand ndle ler rin ina aP PL/ L/SQ SQL Lbl bloc ock? k? Mark Markf for orR Rev evie iew w (1)Points Protectsthedatabasefromerrors Codeismorereadablebecauseerror-handlingroutinescanbewrittenin Codeismorereadablebecauseerror-handlingr outinescanbewrittenin thesameblockinwhichtheerroroccurred Preventserrorsfromoccurring(*) Avoidscostlyandtime-consumingcorrectionofmistakes
Correct 50. 50. Exa Exami mine net the hef fol ollo lowi wing ngc cod ode. e.W Why hyd doe oes sth the eex exce cept ptio ion nha hand nd lernotfollowgoodpracticeguidelines? DECLARE v_salaryemployees.salary%TYPE; BEGIN SELECTsalaryINTOv_salaryFROMemployees WHEREemployee_id=999; EXCEPTION
WHENOTHERSTHEN DBMS_OUTPUT.PUT_LINE('Anerroroccurred'); END; MarkforReview (1)Points YoushouldnotuseDBMS_OUTPUT.PUT_LINEinan YoushouldnotuseDBM S_OUTPUT.PUT_LINEinanexceptionhandler. exceptionhandler. employee_id999doesnotexistintheemployeestable. Theexceptionhandlershouldtestforthename Theexceptionhandler shouldtestforthenamedexceptionNO_DATA_FOUND dexceptionNO_DATA_FOUND. . (*) TheexceptionhandlershouldCOMMITthetransaction.
C o r r ec t