Test:Semester1MidTermExam-PartII 1. APL APL/S /SQL QLb blo loc ckco kcont ntai ains nst the hef fol ollo lowi wing ngc cod ode: e: v_counter:=1; LOOP EXITWHENv_counter=5; v_counter:=v_counter+1; ENDLOOP; WhatisthevalueofV_COUNTERaftertheloopisfinished? MarkforReview (1)Points 5(*) 6 1 Thisisaninfiniteloop;theloopwillneverfinish.
Incorrect.RefertoSection4Lesson3. 2. Whi Which cho one neo of fth thes ese eta task sks sis isb bes est tdo done neu usi sing nga aL LOO OOP Pst stat at ement? ement? MarkforR MarkforReview eview (1)Points Assigningalettergradetoanumericalscore Calculatinganddisplayingthesumofallinte Calculatinganddispla yingthesumofallintegersfrom1to100(*) gersfrom1to100(*) Testingifaconditionistrue,falseornull Fetchinganddisplayinganemployee'slastnam Fetchinganddisplayin ganemployee'slastnamefromthedatabase efromthedatabase
Correct 3. The TheE EXI XIT Tst stat atem emen ent tca can nbe bel loc ocat ated eda any nywh wher ere ein insi side dea ab bas as icloop.TrueorFalse? icloop.TrueorFalse ? MarkforReview (1)Points True(*)
False
Correct 4. Wha What tki kind ndo of fst stat atem emen ent tis isb bes est tsu suit ited edf for ord dis ispl play ayin ing gth th emultiplicationtablefor"sixes":6x1=6,6x2 emultiplicationtable for"sixes":6x1=6,6x2=12...6x12=72? =12...6x12=72? MarkforReview (1)Points CASEexpression IFstatement CASEstatement LOOPstatement(*)
Correct 5.
Wh i c h o n e o f t h e s e i s N O T a ki n d o f l o o p ?
Review (1)Points ASCENDINGloop(*) FORloop Basicloop WHILEloop
Correct 6.
E x a m i n e t h e fo l l o w i n g c o d e :
DECLARE aVARCHAR2(6):=NULL; bVARCHAR2(6):=NULL; BEGIN IFa=bTHEN DBMS_OUTPUT.PUT_LINE('EQUAL'); ELSIFa!=bTHEN DBMS_OUTPUT.PUT_LINE('UNEQUAL'); ELSE DBMS_OUTPUT.PUT_LINE('OTHER');
M a rk f or
ENDIF; END; Whichwordwillbedisplayed? MarkforReview (1)Points UNEQUAL EQUAL Nothingwillbedisplayed OTHER(*)
Correct 7. MarkforReview (1)Points
Wha What tis ist the hec cor orre rect ctf for orm mof ofa as sim impl ple eIF IFs sta tate teme ment nt? ?
IFconditionTHENstatement; IFconditionTHENstatement; ENDIF;(*) IFcondition; THENstatement; ENDIF; IFcondition THENstatement ENDIF;
Correct 8. THEN-ELSE THEN-ELSEstruc structures tures? ? (1)Points
Wha What tis ist the hec cor orre rect ctn nam ame efo for rCA CASE SE, ,LO LOOP OP, ,WH WHIL ILE, E,a and ndI IFFMarkforR MarkforReview eview
Controlstructures(*) Arraystructures
Memorystructures Cursorstructures
Correct 9. MarkforReview (1)Points
Wha What tis ist the hec cor orre rect ctf for orm mof ofa ac com ompo poun und dIF IFs sta tate teme ment nt? ?
IFcondition THENstatement1 ELSEstatement2; IFcondition THENstatement1 ELSEstatement2; ENDIF; IFcondition; THENstatement1; ELSEstatement2; ENDIF; IFconditionTHENstatement1; ELSEstatement2; ENDIF; (*)
Correct 10. 10. Wha What tty type peo of fco cont ntro rol lst stru ruct ctur ures esa are rer rep epet etit itio ion nst stat atem emen en tsthaten tsthatenable ableyout youtoexe oexecute cutestate statements mentsina inaPLSQ PLSQLblo Lblockre ckrepeate peatedly? dly? Markfor Markfor Review (1)Points IFstatements Loops(*) CASEexpressions
CASEstatements
Incorrect.RefertoSection4Lesson1. 11. Howm Howmany anyEL ELSIF SIFst state atemen ments tsare areyo youa uallo llowed wedto toha have vein inac acomp ompoun oundI dIFs Fstat tat ement? ement? MarkforR MarkforReview eview (1)Points Onlyone Asmanyasyouwant(*) Theymustmatchthesamenumberasthenumber Theymustmatchthesa menumberasthenumberofELSEstatements. ofELSEstatements. None;thecommandisELSEIF;
Correct 12. 12. You Youn nee eed dto toe exe xecu cute tea as set eto of fst stat atem emen ents ts1 10 0ti time mes, s,i inc ncre re asingacounterby1eachtime.Whichofthef asingacounterby1e achtime.WhichofthefollowingPL/SQLconstruct ollowingPL/SQLconstructscando scando this? this?(Ch (Choos ooset ethre hree) e) Markf Markfor orRev Review iew (1)Points (Chooseallcorrectanswers) IF...THEN...ELSE AWHILEloop(*) CASE...WHEN...THEN AFORloop(*) Abasicloop(*)
Incorrect.RefertoSection4Lesson1. 13. 13. Wha What twi will llb be eth the eva valu lue eof ofv v_s _sal al_d _des esc caf afte ter rth the efo foll llow owin in gcodeisexecuted? DECLARE v_salaryNUMBER(6,2):=NULL; v_sal_descVARCHAR2(10); BEGIN
CASE WHENv_salary<10000THENv_sal_desc:='LowPaid'; WHENv_salary>=10000THENv_sal_desc:='HighPaid'; ENDCASE; END; MarkforReview (1)Points HighPaid LowPaid Null Thecodewillfailandreturnanexception(*)
Correct 14. 14. Wha What twi will llb be eth the eva valu lue eof ofv v_r _res esul ult taf afte ter rth the efo foll llow owin ing g codeisexecuted? DECLARE v_gradeCHAR(1):=NULL; v_resultVARCHAR2(10); BEGIN CASEv_grade WHEN('A'OR'B')THENv_result:='VeryGood'; WHEN('E'OR'F')THENv_result:='Poor'; ELSEv_result:='InBetween'; ENDCASE; END; MarkforReview (1)Points Poor InBetween(*) Null VeryGood
Correct 15. 15. deisexecuted? DECLARE
Wha What tva valu lue ewi will llv v_a _ans nswe wer rco cont ntai ain naf afte ter rth the efo foll llow owin ing gco co
v_ageNUMBER:=18; v_answerVARCHAR2(10); BEGIN v_answer:= CASE WHENv_age<25THEN'Young' WHENv_age=18THEN'Exactly18' ELSE'Older' ENDCASE; END; MarkforReview (1)Points Exactly18 Young(*) Null Older
Correct 16. 16. Wha What twi will llb be eth the eva valu lue eof ofv var aria iabl ble ec caf afte ter rth the efo foll llow owin in gcodeisexecuted? DECLARE aBOOLEAN:=TRUE; bBOOLEAN:=NULL; cNUMBER; BEGIN IFaANDbTHENc:=2; ELSIFaORbTHENc:=0; ELSEc:=1; ENDIF; END; MarkforReview (1)Points 1 Null 0(*) 2
Correct
17. 17. You Youw wan ant tto toa ass ssig ign na ava valu lue eto tov v_r _res esul ult twh whic ich hde depe pend nds son on thevalueofv_grade:ifv_grade='A'setv_ thevalueofv_grade: ifv_grade='A'setv_resultto'VeryGood'and resultto'VeryGood'andsoon. soon. DECLARE v_gradeCHAR(1); v_resultVARCHAR2(10); BEGIN v_result:= CASEv_grade Thenextlineshouldbe MarkforReview (1)Points WHENv_grade='A'THEN'VeryGood' WHEN'A'THEN'VeryGood'; WHEN'A'THENv_result:='VeryGood'; WHEN'A'THEN'VeryGood'(*)
Correct 18.
Wha What tki kind nds sof ofl loo oops psc can anb be ene nest sted ed? ?
Mark Markf fo orRe rRevi view ew
(1)Points BASICloops WHILEloops FORloops Alloftheabove(*)
Correct 19. 19. Whe When nco codi ding ngt two won nes este ted dlo loop ops, s,b bot oth hlo loop ops smu must stb be eof oft the he sametype.Forexample,youcannotcodeaFORloopinsideaWHILEloop sametype.Forexample,youcannotcodeaFOR loopinsideaWHILEloop.Trueor .Trueor False? MarkforReview (1)Points True
False(*)
Correct 20. 20. You Youwa want ntt to odi disp spla lay ymu mult ltip ipli lica cati tion ont tab able les sfo for rnu numb mber ers sup up to12.Thedisplayshouldlooklikethis: 1x1=1 1x2=2 ..... 1x12=12 2x1=2 2x2=4 ..... 2x12=24 3x1=3 ..... ..... 12x12=144 Whichofthefollowingisanefficientwayto Whichofthefollowing isanefficientwaytodothisinPL/SQL? dothisinPL/SQL? MarkforReview (1)Points UsetwonestedFORloops.(*) Storeallthenumbersfrom1to144inatable,thenfetchanddisplay Storeallthenumbersfrom1to144inatable ,thenfetchanddisplayt t hemusingacursor. CreateafunctionwhichacceptstwonumbersasINparametersandreturn Createafunctionwhichacceptstwonumbersas INparametersandreturns s theirproduct.Invokethefunction144times. Writeananonymousblockwhichcontains144callstoDBMS_OUTPUT,each Writeananonymousblockwhichcontains144ca llstoDBMS_OUTPUT,eachl l ookinglike:DBMS_OUTPUT.PUT_LINE('7x9=63');
Correct 21. Exam Examin ine eth the ef follo ollowi wing ngc cod ode: e: DECLARE v_outer_countNUMBER:=1; v_inner_countNUMBER:=1; BEGIN LOOP LOOP v_inner_count:=v_inner_count+1; EXITWHENv_inner_count>5;--LineA ENDLOOP; v_outer_count:=v_outer_count+1; EXITWHENv_outer_count>3; ENDLOOP;
END; WhathappensatLineAwhenthevalueofV_INN WhathappensatLineA whenthevalueofV_INNER_COUNTequals6? ER_COUNTequals6? MarkforReview (1)Points Bothloopsareexitedandtheblock'sexecutionisterminated. Theinnerloopisexitedbuttheouterloopco Theinnerloopisexit edbuttheouterloopcontinuesexecution.(*) ntinuesexecution.(*) Theouterloopisexitedbuttheinnerloopco Theouterloopisexit edbuttheinnerloopcontinuesexecution. ntinuesexecution. Anerrorconditionisreturned.
Correct 22. 22. In Ina aWH WHIL ILE Elo loop op, ,th the est stat atem emen ents tsi ins nsid ide eth the elo loop opm mus ust tex ex ecute ecuteat atlea least stonc once. e.Tru Trueo eorF rFals alse? e? Markf Markfor orRev Review iew (1)Points True False(*)
Correct 23. 23. Whi Which chs sta tate teme ment ntb bes est tde desc scri ribe bes swh when ena aF FOR ORl loo oop psh shou ould ldb b eused? MarkforReview (1)Points Whenthenumberofiterationsisknown(*) WhentestingthevalueinaBooleanvariable Whenthecontrollingconditionmustbeevaluat Whenthecontrollingc onditionmustbeevaluatedatthestartofeachi edatthestartofeachit t eration
Correct 24. 24. BEGIN
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?
FORiin1..3LOOP DBMS_OUTPUT.PUT_LINE(i); i:=i+1; ENDLOOP; END; MarkforReview (1)Points Itwilldisplay1,2,3. Itwilldisplay2,3,4. ItwillresultinanerrorbecauseyoucannotmodifythecounterinaF Itwillresultinanerrorbecauseyoucannot modifythecounterinaFO O Rloop.(*) Itwillresultinanerrorbecausethecounter Itwillresultinane rrorbecausethecounterwasnotexplicitlydecla wasnotexplicitlydeclar r ed.
Correct 25 .
E x a m i n e t he f o l l o w i n g c o d e:
DECLARE v_boolBOOLEAN:=FALSE; v_counterNUMBER(4):=0; BEGIN ...LineA END; WhichofthefollowingisNOTvalidatlineA? MarkforReview (1)Points WHILENOTv_booleanLOOP WHILEv_booleanANDv_counter<6LOOP WHILEv_counter>8LOOP WHILEv_counterIN1..5LOOP(*)
Correct 26. 26. efollowin efollowingis gistrue true? ?
Whe When nus usin ing ga aco coun unte ter rto toc con ontr trol ola aF FOR ORl loo oop, p,w whi hich cho of fth th MarkforR MarkforReview eview
(1)Points Youmusthaveexactlyonecounterbutitisim Youmusthaveexactly onecounterbutitisimplicitlydeclared.(*) plicitlydeclared.(*) Youmusthaveexactlyonecounterandyoumust Youmusthaveexactly onecounterandyoumustexplicitlydeclareit. explicitlydeclareit. Youcanhavemultiplecounters,butyouneedatleastone. Youdon'tneedacounter;youcantestforany Youdon'tneedacount er;youcantestforanything(forexample,wheth thing(forexample,whethe e raBOOLEANisTRUEorFALSE).
Correct
Section5 (Answerallquestionsinthissection) 27. 27. The Thef fol ollo lowi wing ngc cur urso sor rha has sbe been end dec ecla lare red: d: CURSORemp_cursIS SELECTfirst_name,last_name,job_id,salary FROMemployees; Whichofthefollowingcorrectlydeclaresacompositerecordwiththes Whichofthefollowingcorrectlydeclaresaco mpositerecordwiththesamestruc amestruc tureasthecursor? MarkforReview (1)Points emp_recemp_rec%ROWTYPE; emp_recemp_curs%TYPE; emp_recemp_curs%ROWTYPE;(*) emp_reccursor%ROWTYPE;
Correct 28. 28. sorattrib sorattributei uteistru strue? e? (1)Points
Whi Which cho of fth the efo foll llow owin ing gst stat atem emen ents tsa abo bout utt the he% %IS ISOP OPEN ENc cur ur MarkforR MarkforReview eview
Youcanissuethe%ISOPENcursorattributeonl Youcanissuethe%ISO PENcursorattributeonlywhenacursorisopen. ywhenacursorisopen.
Youcanissuethe%ISOPENcursorattributeonl Youcanissuethe%ISO PENcursorattributeonlywhenmorethanonereco ywhenmorethanonerecor r disreturned. Youcanissuethe%ISOPENcursorattributewhe Youcanissuethe%ISO PENcursorattributewhenacursorisopenorclo nacursorisopenorclos s ed.(*) Ifacursorisopen,thenthevalueof%ISOPENisfalse.
Correct 29. 29. The TheD DEP EPAR ARTM TMEN ENTS TSt tab able lec con onta tain ins sfo four urc col olum umns ns. .Ex Exam amin ine eth th efollowingcode: DECLARE CURSORdept_cursIS SELECT*FROMdepartments; v_dept_recdept_curs%ROWTYPE; BEGIN OPENdept_curs; FETCHdept_cursINTOv_dept_rec; ... Whichoneofthefollowingstatementsistrue? MarkforReview (1)Points v_dept_reccontainsthefirstfourrowsofthe v_dept_reccontainsth efirstfourrowsofthedepartmentstable. departmentstable. TheFETCHwillfailbecausethestructureofv_dept_recdoesnotmatch TheFETCHwillfailbecausethestructureofv _dept_recdoesnotmatcht t hestructureofthecursor. v_dept_reccontainsthefirstrowofthedepartmentstable.(*) Theblockwillfailbecausethedeclarationof Theblockwillfailbe causethedeclarationofv_dept_recisinvalid. v_dept_recisinvalid.
Correct 30. 30. The Thee emp mplo loye yees est tab able lec con onta tain ins s11 11c col olum umns ns. .Th The efo foll llow owin ing g blockdeclaresacursorandarecordbasedonthecursor: DECLARE CURSORemp_cursIS SELECT*FROMemployees; v_emp_recemp_curs%ROWTYPE; Atwelfthcolumnisnowaddedtotheemployeestable.Whichofthefoll Atwelfthcolumnisnowaddedtotheemployees table.Whichofthefollowingsta owingsta tementsistrue?
MarkforReview (1)Points Thedeclarationofemp_recmustbechangedto Thedeclarationofemp _recmustbechangedtoaddanextrafield. addanextrafield. Theblockwillstillworkcorrectlywithoutan Theblockwillstillw orkcorrectlywithoutanychangestothePL/SQLc ychangestothePL/SQLco o de.(*) TheblockwillfailandanINVALID_CURSORexce Theblockwillfailan danINVALID_CURSORexceptionwillberaised. ptionwillberaised. Anextrascalarvariablemustbedeclaredtoc Anextrascalarvariab lemustbedeclaredtocorrespondtothetwelfth orrespondtothetwelftht t ablecolumn.
Correct 31. Anim Animpli plicit citcu curso rsorc rcan anbe beuse usedf dfor oram amult ultipl iple-r e-row owSEL SELECT ECTst state atemen ment. t.Tru Tru eor eorF Fal alse se? ? Mark Markf for orR Rev evie iew w (1)Points True False(*)
Correct 32. 32.
Pla Place cet the hef fol ollo lowi wing ngs sta tate teme ment nts sin int the hec cor orre rect cts seq eque uenc nce: e:
OPENmy_curs; CLOSEmy_curs; CURSORmy_cursISSELECTmy_columnFROMmy_table; FETCHmy_cursINTOmy_variable; MarkforReview (1)Points C,D,A,B C,A,D,B(*) A,C,D,B C,A,B,D
Correct
33. 33. An Anex expl plic icit itc cur urso sor rmu must sta alw lway ays sbe bed dec ecla lare red, d,o ope pene ned dan and d closedbythePL/SQLprogrammer.TrueorFalse? closedbythePL/SQLprogrammer.TrueorFalse ? MarkforReview (1)Points True False(*)
Correct 34. 34. Whi Which cho of fth thes ese eco cons nstr truc ucts tsc can anb be eus used edt to ofe fetc tch hmu mult ltip iple le row rows sfr from oma ac cur urso sor' r's sac acti tive ves set et? ? Mark Markf for orR Rev evie iew w (1)Points ACASEstatement AnIF....ELSEstatement AbasicloopwhichincludesFETCHandEXITWHENstatements(*) AbasicloopwhichincludesOPEN,FETCHandCLOSEstatements
Correct 35. 35. MarkforReview (1)Points
Whi Which cho of fth thes ese eis isN NOT OTa av val alid idc cur urso sor rde decl clar arat atio ion? n?
CURSORemp_cursIS SELECTsalary FROMemployees ORDERBYsalaryDESC; CURSORemp_cursIS SELECTsalary FROMemployees WHERElast_nameLIKE'S%'; CURSORemp_dept_cursIS SELECTe.salary,d.department_name FROMemployeese,departmentsd WHEREe.department_id=d.department_id;
CURSORemp_cursIS SELECTsalaryINTOv_salary FROMemployees; (*)
Correct 36. 36. Aft After era ac cur urso sor rha has sbe been enc clo lose sed, d,i it tca can nbe beo ope pene ned dag agai ain n int inthe hes sam ame ePL PL/S /SQL QLb blo lock ck. .Tr True ueo or rFa Fals lse? e? Mark Markf for orR Rev evie iew w (1)Points True(*) False
Correct 37. 37. Whi Which cho of fth thes ese est stat atem emen ents tsa abo bout uti imp mpli lici cit tcu curs rsor ors sis isN NOT OT true? true? MarkforR MarkforReview eview (1)Points TheyaredeclaredautomaticallybyOraclefor Theyaredeclaredauto maticallybyOracleforsingle-rowSELECTstateme single-rowSELECTstatemen n ts. TheyaredeclaredautomaticallybyOraclefor Theyaredeclaredauto maticallybyOracleforallDMLstatements. allDMLstatements. TheyaredeclaredbythePL/SQLprogrammer.(*) TheyareopenedandclosedautomaticallybyOracle.
Correct 38. 38. 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? DECLARECURSORemp_cursIS SELECTsalaryFROMemployees; v_salaryemployees.salary%TYPE; BEGIN OPENemp_curs; FETCHemp_cursINTOv_salary; CLOSEemp_curs; FETCHemp_cursINTOv_salary; END; MarkforReview (1)Points
TheblockwillfailandanINVALID_CURSORexce Theblockwillfailan danINVALID_CURSORexceptionwillberaised.(*) ptionwillberaised.(*) Thefirstemployeerowwillbefetchedtwice. Thefirsttwoemployeerowswillbefetched. TheblockwillfailandaTOO_MANY_ROWSexcept Theblockwillfailan daTOO_MANY_ROWSexceptionwillberaised. ionwillberaised.
Correct 39. 39.
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 CURSORemp_cursIS SELECTsalaryFROMemployees; v_salaryemployees.salary%TYPE; BEGIN FETCHemp_cursINTOv_salary; DBMS_OUTPUT.PUT_LINE(v_salary); CLOSEemp_curs; END; MarkforReview (1)Points Thefirstemployee'ssalarywillbefetchedanddisplayed. Allemployees'salarieswillbefetchedanddisplayed. Theexecutionwillfailandanerrormessagew Theexecutionwillfai landanerrormessagewillbedisplayed.(*) illbedisplayed.(*) Thelowestsalaryvaluewillbefetchedanddisplayed.
Correct 40. 40. You Youw wan ant tto tod dis ispl play aya all lll loc ocat atio ions ns, ,an and dth the ede depa part rtme ment nts s ineachlocation.Examinethefollowingcode: DECLARE CURSORloc_cursISSELECT*FROMlocations; CURSORdept_curs(p_loc_idNUMBER)IS SELECT*FROMdepartmentsWHERElocation_id=p_loc_id; BEGIN FORloc_recINloc_cursLOOP DBMS_OUTPUT.PUT_LINE(loc_rec.city); FORdept_recINdept_curs(--PointA--)LOOP DBMS_OUTPUT.PUT_LINE(dept_rec.department_name); ENDLOOP;
ENDLOOP; END; WhatshouldyoucodeatPointA? MarkforReview (1)Points p_loc_id location_id null LOOP...ENDLOOP; loc_rec.location_id(*)
Correct 41. When Whenusi using ngmul multip tiple lenes nested tedcu curso rsors, rs,wh what atkin kinds dsof ofloo loops pscan canyo youu uuse? se? MarkforReview (1)Points CursorFORloopsonly. Basicloopsonly. WHILEloopsonly. Noneoftheabove. Alloftheabove.(*)
Correct 42. 42. singlePL singlePL/SQL /SQLblock block? ? (1)Points Oneortwo. Onlyone.
How Howm man any yex expl plic icit itc cur urso sors rsc can anb be ede decl clar ared eda and ndu use sed din ina a MarkforR MarkforReview eview
Asmanyasneeded.(*) Uptoeightcursors. Noneoftheabove.
Correct 43.
Exa Exami mine net the hef fol ollo lowi wing ngc cod ode: e:
DECLARE CURSORcISSELECT*FROMemployeesFORUPDATE; c_recc%ROWTYPE; BEGIN OPENc; FORiIN1..20LOOP FETCHcINTOc_rec; IFi=6THEN UPDATEemployeesSETfirst_name='Joe' WHERECURRENTOFc; ENDIF; ENDLOOP; CLOSEc; END; Whichemployeeroworrowswillbeupdatedwhe Whichemployeerowor rowswillbeupdatedwhenthisblockisexecuted? nthisblockisexecuted? MarkforReview (1)Points Thefirst6fetchedrowswillbeupdated. Norowswillbeupdatedbecauseyoulockedthe Norowswillbeupdate dbecauseyoulockedtherowswhenthecursorwas rowswhenthecursorwas opened. The6thfetchedrowwillbeupdated.(*) Theblockwillnotcompilebecausethecursorshouldhavebeendeclared Theblockwillnotcompilebecausethecursor shouldhavebeendeclared ....FORUPDATEWAIT5; Noneoftheabove.
Correct 44. 44. Use User rTO TOM Mha has slo lock cked eda ar row owi in nth the eWO WORK RKER ERS Sta tabl ble. e.N Now ow, ,us us erDICKwantstoopenthefollowingcursor:
CURSORcIS SELECT*FROMworkersFORUPDATENOWAIT; WhatwillhappenwhenDICKopensthecursoran Whatwillhappenwhen DICKopensthecursorandtriestofetchrows? dtriestofetchrows? MarkforReview (1)Points TOM'ssessionisrolledback.DICK'ssessions TOM'ssessionisrolle dback.DICK'ssessionsuccessfullyfetchesrows uccessfullyfetchesrowsf f romthecursor. DICK'ssessionwaitsindefinitely. Bothsessionswaitforafewseconds;thenthesystembreaksalllocks Bothsessionswaitforafewseconds;thenthe systembreaksalllocksa a ndbothsessionsraiseanexception. DICK'ssessionimmediatelyraisesanexception.(*) Thec%NOWAITattributeissettoTRUE.
Correct 45. 45. You Youw wan ant tto tod dec ecla lare rea ac cur urso sor rwh whic ich hlo lock cks sea each chr row owf fet etch ch edbythecursor.Examinethefollowingcode: DECLARE CURSORemp_cursIS SELECT*FROMemployees FOR--PointA WhichofthefollowingcanNOTbecodedatPointA? MarkforReview (1)Points UPDATE; UPDATEOFsalary; UPDATEOFemployees;(*) UPDATENOWAIT;
Correct
46. 46. Whe When nus usin ing ga acu curs rsor orF FOR ORl loo oop, p,O OPE PEN, N,C CLO LOSE SEa and ndF FET ETCH CHs sta ta tementsshouldnotbeexplicitlycoded.Trueo tementsshouldnotbe explicitlycoded.TrueorFalse? rFalse? MarkforReview (1)Points True(*) False
Correct 47. 47.
Wha What tis isw wro rong ngw wit ith hth the efo foll llow owin ing gco code de? ?
DECLARE CURSORdept_cursISSELECT*FROMdepartments; BEGIN FORdept_recINdept_cursLOOP DBMS_OUTPUT.PUT_LINE(dept_curs%ROWCOUNT DBMS_OUTPUT.PUT _LINE(dept_curs%ROWCOUNT||dept_rec.department_n ||dept_rec.department_name): ame): ENDLOOP; DBMS_OUTPUT.PUT_LINE(dept_rec.department_id); END; MarkforReview (1)Points ThecursorDEPT_CURShasnotbeenopened. TheimplicitlydeclaredrecordDEPT_RECcannot Theimplicitlydeclare drecordDEPT_RECcannotbereferencedoutsideth bereferencedoutsidethe e cursorFORloop.(*) Youcannotuse%ROWCOUNTwithacursorFORloop. ThecursorDEPT_CURShasnotbeenclosed. Nothingiswrong,thiscodewillexecutesuccessfully.
Incorrect.RefertoSection5Lesson3. 48. 48. Exa Exami mine net the hef fol ollo lowi wing ngc cod ode. e.T To odi disp spla lay yth the esa sala lary ryo of fan an employee,whatmustbecodedatPointA? DECLARE CURSORemp_cursISSELECT*FROMemployees; BEGIN FORemp_recINemp_cursLOOP DBMS_OUTPUT.PUT_LINE(--whatgoeshere?); ENDLOOP; END; MarkforReview (1)Points
salary emp_curs.salary emp_rec.salary(*) employees.salary emp_rec.salaryINemp_curs
Incorrect.RefertoSection5Lesson3. 49. 49. The There rea are re1 12 2di dist stin inct ctJ JOB OB_I _IDs Dsi in nth the eEM EMPL PLOY OYEE EES Sta tabl ble. e.Y Y ouneedtowritesomePL.SQLcodetofetchanddisplayalltheemployee ouneedtowritesomePL.SQLcodetofetchand displayalltheemployeeswitha switha specificJOB_ID.ThechosenJOB_IDcanbediff specificJOB_ID.Thec hosenJOB_IDcanbedifferenteachtimethecode erenteachtimethecodeisexecut isexecut ed. What Whati is sth the ebe best stw way ayt to odo dot thi his? s? Mark Markf for orR Rev evie iew w (1)Points Write12separatePL/SQLblocks,eachdeclarin Write12separatePL/S QLblocks,eachdeclaringacursorwithadiffere gacursorwithadifferen n tJOB_IDintheWHEREclause. WriteasinglePL/SQLblockwhichdeclares12cursors,oneforeachdis WriteasinglePL/SQLblockwhichdeclares12 cursors,oneforeachdist t inctvalueofJOB_ID. WriteasinglePL/SQLblockwhichdeclaresonecursorusingaparameter WriteasinglePL/SQLblockwhichdeclaresone cursorusingaparameter fortheJOB_ID.(*) WriteasinglePL/SQLblockwhichusesacursortofetchalltheemploy WriteasinglePL/SQLblockwhichusesacurso rtofetchalltheemploye e erows,withanIFstatementtodecidewhicho erows,withanIFsta tementtodecidewhichofthefetchedrowstodis fthefetchedrowstodisplay. play.
Correct
a c u rs o r ? (1)Points
50. 50. Wha What tis iso one neo of fth the ead adva vant ntag ages eso of fus usin ing gpa para rame mete ters rsw wit ith h Ma r k fo r Re v i ew
YoucanuseacursorFORloop. YoucandeclarethecursorFORUPDATE. YoudonotneedtoDECLAREthecursoratall.
Youcanuseasinglecursortofetchadifferentsetofrowseachtime Youcanuseasinglecursortofetchadiffere ntsetofrowseachtimet t hecursorisopened.(*) Itwillexecutemuchfasterthanacursorwithoutparameters.
Correct