Professional Documents
Culture Documents
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk
(*)indicatesacorrectanswer.
Section9
1.WhichofthefollowingstatementsaboutpackagesisNOTtrue?
MarkforReview
(1)Points
Allproceduresandfunctionsmustbedeclaredinthespecification.(*)
Cursorscanbedeclaredinthespecification.
Thebodycontainsthedetailedcodeofthesubprograms.
Variablescanbedeclaredinthebody.
Thespecificationmustbecreatedbeforethebody.
Correct
2.Thefollowingpackagespecificationhasbeencreated:CREATEOR
REPLACEPACKAGEmypackIS
FUNCTIONmyfunc(p_funcparamDATE)RETURNBOOLEAN;
PROCEDUREmyproc(p_procparamINNUMBER);
ENDmypack;
Whichofthefollowingwillcorrectlyinvokethepackagesubprograms?
(Choosetwo.)
MarkforReview
(1)Points
(Chooseallcorrectanswers)
mypack.myfunc('22JAN07');
mypack.myproc(35);
(*)
IFNOTmypack.myfunc(SYSDATE)THEN
DBMS_OUTPUT.PUT_LINE('Message');
ENDIF;
(*)
myproc(40);
v_num:=mypack.myproc(22);
Correct
3.WhichoneofthefollowingcanNOTbepartofaPackage?Mark
forReview
(1)Points
Procedures
Explicitcursors
Triggers(*)
Functions
Globalvariables
Correct
4.Whatiswrongwiththefollowingsyntaxforcreatingapackage
specification?
CREATEORREPLACEPACKAGEmypackIS
g_constant1NUMBER(6):=100;
FUNCTIONfunc1(p_param1INVARCHAR2);FUNCTIONfunc2;
ENDmypack;
MarkforReview
(1)Points
Youcannotdeclareconstantsinthespecification.
Apackagemustcontainatleastoneprocedure.
TheRETURNdatatypeofthefunctionsmustbespecified.
(*)
Thefirstlineshouldbe:
CREATEORREPLACEPACKAGESPECIFICATIONmypackIS
Nothingiswrong,thiscodecontainsnoerrors.
Correct
5.Whichofthefollowingstatementsaboutapackageinitialization
blockistrue?MarkforReview
(1)Points
ItcannotcontainanySQLstatements.
Itisananonymousblockattheendofapackagebody.(*)
Itisaprocedureinapackagethatmustbeinvokedbeforetherestof
thepackagecanbeused.
Itisananonymousblockinthepackagespecification.
Itisexecutedautomaticallyeverytimeanyglobalvariableinthe
packageisreferenced.
Correct
6.PackageHRPACKcontainsthefollowingpublicfunction:
FUNCTIONempfunc(p_deptnoNUMBER)RETURNNUMBERIS
BEGIN
UPDATEemployeesSETsalary=salary*1.1WHEREdepartment_id=
p_deptno;
RETURNSQL%ROWCOUNT;ENDempfunc;
WhatwillhappenwhenthefollowingSQLstatementisexecuted?
SELECTdepartment_name,hrpack.empfunc(department_id)FROM
departments;
MarkforReview
(1)Points
TheSELECTwillfailbecauseyoucannotreturnSQL%ROWCOUNT
fromapackagedfunction.
TheSELECTwillfailbecauseyoucannotcallpackagedfunctions
fromwithinaSQLstatement.
TheSELECTwillfailbecauseyoucannotexecuteaDMLstatement
fromwithinaquery.
TheSELECTwillsucceedbecauseitisreferencingadifferenttable
fromthefunction.(*)
Correct
7.PackageTAXPACKdeclaresaglobalvariableG_TAXRATE
NUMBER(2,2)
.ThevalueofthetaxrateisstoredintableTAXTABinthedatabase.
YouwanttoreadthisvalueautomaticallyintoG_TAXRATEeachtime
ausersessionmakesitsfirstcalltoTAXPACK.Howwouldyoudo
this?
MarkforReview
(1)Points
Declaretheglobalvariableas:
g_taxrateNUMBER(2,2):=SELECTtax_rateFROMtaxtab;
Createadatabasetriggerthatincludesthefollowingcode:SELECT
tax_rateINTOtaxpack.g_taxrateFROMtaxtab;
AddaprivatefunctiontothepackagebodyofTAXPACK,and
invokethefunctionfromtheusersession.
AddapackageinitializationblocktothepackagebodyofTAXPACK.
(*)
Correct
8.Weneverneedtouseaforwarddeclarationwheninvokingapublic
subprogram.TrueorFalse?MarkforReview
(1)Points
True(*)
False
Correct
9.WeneedtodeclareapackagevariablenamedMYVAR,whichcan
bereferencedbyanysubprograminthepackagebutcanNOTbe
referencedfromoutsidethepackage.Inthefollowingcode,where
shouldMYVARbedeclared?
CREATEORREPLACEPACKAGEvarpackISPointA
...
ENDvarpack;
CREATEORREPLACEPACKAGEBODYvarpackIS
PointBPROCEDUREvarprocIS
PointC
BEGIN
...
ENDvarproc;
PROCEDURE...
...
PointD
ENDvarpack;
MarkforReview
(1)Points
PointA
PointB(*)
PointC
PointD
PointBorPointC,theywillbothwork
Correct
10.Inapackage,publiccomponentsaredeclaredinthespecification
butprivatecomponentsarenot.TrueorFalse?MarkforReview
(1)Points
True(*)
False
Correct
Page1of5
Test:MidTermExamSemester2
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk
(*)indicatesacorrectanswer.
Section9
11.Wewanttoremovethespecification(butnotthebody)ofpackage
BIGPACKfromthedatabase.Whichofthefollowingcommandswilldo
this?MarkforReview
(1)Points
DROPPACKAGEbigpack;
DROPPACKAGESPECIFICATIONbigpack;
DROPPACKAGEbigpackSPECIFICATION;
DROPPACKAGEHEADERbigpack;
Noneoftheabove(*)
Correct
12.Whichofthefollowingwilldisplaythedetailedcodeofthesubp
rogramsinpackageDEPTPACKinyourschema?MarkforReview
(1)Points
SELECTtextFROMUSER_SOURCE
WHEREname='DEPTPACK'
ANDtype='PACKAGE'
ORDERBYline;
SELECTtextFROMUSER_SOURCEWHEREname=
'DEPTPACK'
ANDtype='PACKAGEBODY'ORDERBYline;
(*)
SELECTtextFROMUSER_SOURCE
WHEREobject_name='DEPTPACK'
ANDobject_type='PACKAGEBODY'
ORDERBYline;
SELECTtextFROMUSER_SOURCE
WHEREname='DEPTPACK'
ANDtype='BODY'
ORDERBYline;
Correct
13.PackageOLDPACKisinyourschema.Whatwillhappenwhenthe
followingstatementisexecuted?
DROPPACKAGEoldpack;MarkforReview
(1)Points
Thebodywillbedroppedbutthespecificationwillberetained.
Thespecificationwillbedroppedbutthebodywillberetained.
Boththespecificationandthebodywillbedropped.(*)
Thestatementwillfailbecauseyoumustdropthebodybeforeyou
candropthespecification.
Correct
14.Examinethefollowingpackagespecification:CREATEOR
REPLACEPACKAGEtaxpackIS
CURSORempcursISSELECT*FROMemployees;PROCEDURE
taxproc;
ENDmypack;
ThepackagebodyofTAXPACKalsoincludesafunctioncalled
TAXFUNC.WhichoneofthefollowingstatementsisNOTtrue?
MarkforReview
(1)Points
Theprocedurecanbeinvokedby:BEGIN
taxpack.taxproc;
END;
Thepackaagewillnotcompilebecauseyoucannotdeclareacursorin
thespecification.
(*)
TAXPROCisapublicprocedureandTAXFUNCisaprivatefunction
TAXPROCcaninvokeTAXFUNCifTAXPROCiscodedbefore
TAXFUNC
TAXPROCcanopenthecursor
Correct
15.PackageNEWPACKcontainsseveralproceduresandfunctions,inc
ludingprivatefunctionPRIVFUNC.FromwherecanPRIVFUNCbe
invoked?(Choosetwo.)MarkforReview
(1)Points
(Chooseallcorrectanswers)
Fromananonymousblock
FromanyprocedureinNEWPACK(*)
Fromanyprivatefunctioninanotherpackage
FromanyfunctioninNEWPACK(*)
Fromanypublicprocedureinanotherpackage
Correct
16.TheDBMS_OUTPUT.PUTprocedureplacestextinabufferbut
doesnotdisplaythecontentsofthebuffer.TrueorFalse?Markfor
Review
(1)Points
True(*)
False
Correct
17.Whichofthefollowingbestdescribesthepurposeofthe
UTL_FILEpackage?MarkforReview
(1)Points
Itisusedtoloadbinaryfilessuchasemployees'photosintothe
database.
Itisusedtoreadandwritetextfilesstoredoutsidethedatabase.(*)
Itisusedtofindouthowmuchfreespaceisleftonanoperating
systemdisk.
ItisusedtoqueryCHARandVARCHAR2columnsintables.
Correct
18.WhyisitbettertouseDBMS_OUTPUTonlyinanonymous
blocks,notinsidestoredsubprogramssuchasprocedures?Markfor
Review
(1)Points
BecauseDBMS_OUTPUTcannotbeusedinsideprocedures
Becauseanonymousblocksdisplaymessageswhiletheblockis
executing,whileproceduresdonotdisplayanythinguntiltheirexecution
hasfinishe
d
BecauseDBMS_OUTPUTshouldbeusedonlyfortestingand
debuggingPL/SQLcode(*)
BecauseDBMS_OUTPUTcanraiseaNO_DATA_FOUND
exceptionifusedinsideapackagedprocedure
Correct
19.TheUTL_FILEpackagecanbeusedtocreatebinaryfilessuchas
JPEGsaswellastextfiles.TrueorFalse?MarkforReview
(1)Points
True
False(*)
Correct
20.Youwanttocreateafunctionwhichdropsatable.Youwritethe
followingcode:
CREATEORREPLACEFUNCTIONdroptab(p_tab_nameIN
VARCHAR2)
RETURNBOOLEANISBEGIN
DROPTABLEp_tab_name;RETURNTRUE;
EXCEPTION
WHENOTHERSTHENRETURNFALSE;
END;
Whywillthisprocedurenotcompilesuccessfully?MarkforReview
(1)Points
Becauseyoucanneverdropatablefrominsideafunction
BecausethePL/SQLcompilercannotcheckiftheargumentof
p_tab_nameisavalidtablename(*)
Becauseyoudonothavetheprivilegeneededtodropatable
BecauseyoucannotuseRETURNintheexceptionsection
Correct
Page2of5
Test:MidTermExamSemester2
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk
(*)indicatesacorrectanswer.
Section9
21.MARYwantsHENRYtobeabletoqueryherEMPLOYEEStable.
Maryexecutesthefollowingcode:
DECLARE
v_grant_stmtVARCHAR2(50);BEGIN
v_grant_stmt:='GRANTSELECTONemployeesTOhenry';
DBMS_SQL.EXECUTE(v_grant_stmt);
END;
MaryhassuccessfullygrantedtheprivilegetoHenry.TrueorFalse?
MarkforReview
(1)Points
True
False(*)
Correct
22.Examinethefollowingcode:
CREATEORREPLACEPROCEDUREmyprocIS
CURSORc_cursISSELECTview_nameFROMuser_views;BEGIN
FORv_curs_recINc_cursLOOP
EXECUTEIMMEDIATE'DROPVIEW'||v_curs_rec.view_name;
ENDLOOP;
END;
Whatwillhappenwhenthisprocedureisinvoked?MarkforReview
(1)Points
Allviewsintheuser'sschemawillbedropped.(*)
TheprocedurewillnotcompilesuccessfullybecausethesyntaxofE
XECUTEIMMEDIATEisincorrect.
TheprocedurewillraiseanexceptionbecauseDynamicSQLcandrop
tablesbutcannotdropviews.
Theprocedurewillraiseanexceptionbecauseoneoftheviewsisa
complexview.
Correct
23.TheeasiestwaytoincludeDDLstatementsinaPL/SQLblockisto
usetheDBMS_SQLpackage.TrueorFalse?MarkforReview
(1)Points
True
False(*)
Correct
24.PackageMULTIPACKdeclaresthefollowingglobalvariable:
g_myvarNUMBER;
UserDICKexecutesthefollowing:multipack.g_myvar:=45;
UserHAZELnowconnectstothedatabase.Bothusersimmediately
execute
:
BEGIN
DBMS_OUTPUT.PUT_LINE(multipack.g_myvar);
END;
WhatvalueswillDickandHazelsee?MarkforReview
(1)Points
Dick:45,Hazel:45
Dick:45,Hazel:0
Dick:45,Hazel:null(*)
Dick:0,Hazel:0
Bothquerieswillfailbecausethesyntaxof
DBMS_OUTPUT.PUT_LINEisincorrect
Correct
25.Whenausersessionchangesthevalueofapackagevariable,the
new
valuecanimmediatelybeseenbyothersessions.TrueorFalse?Mark
forReview
(1)Points
True
False(*)
Correct
Section10
26.Inthefollowingcode:CREATETRIGGERmytrigg
INSTEADOFINSERTORUPDATEONmy_object_nameFOR
EACHROW
BEGIN...
my_object_namecanbethenameofatable.TrueorFalse?Markfor
Review
(1)Points
True
False(*)
Correct
27.INSTEADOFtriggersarealwaysrowtriggers,evenifFOREACH
ROWisomitted.TrueorFalse?MarkforReview
(1)Points
True(*)
False
Correct
28.WhichofthefollowingcanNOTbecodedinthebodyofaDML
trigger?(Choosetwo.)MarkforReview
(1)Points
(Chooseallcorrectanswers)
IFDELETINGTHEN
IFSELECTINGTHEN(*)
IFINSERTINGTHEN
IFUPDATING('JOB_ID')THEN
IFOTHERSTHEN(*)
Correct
29.Withwhichkindoftriggercanthe:OLDand:NEWqualifiersbe
used?MarkforReview
(1)Points
DDLtriggers
DatabaseEventtriggers
Statementtriggers
Rowtriggers(*)
AFTERtriggers
Correct
30.MARYandJOE'sschemaseachcontainanEMPLOYEEStable.
JOEcre
atesthefollowingtrigger:CREATETRIGGERupd_trigg
AFTERDELETEONjoe.employeesFOREACHROW
BEGIN
DELETEFROMmary.employees
WHEREemployee_id=:OLD.employee_id;END;
AthirduserTOMneedstodeleterowsfromJOE'sEMPLOYEEStable.
WhatobjectprivilegeswillTOMandJOEneed?
MarkforReview
(1)Points
TOMdoesnotneedanyobjectprivileges,butJOEneedsDELETE
onbothTOM.EMPLOYEESandMARY.EMPLOYEES
TOMneedsDELETEonJOE.EMPLOYEESandJOEneeds
DELETEonMARY.EMPLOYEES(*)
JOEdoesnotneedanyobjectprivileges,butTOMneedsDELETEon
MARY.EMPLOYEES
TOMneedsDELETEonMARY.EMPLOYEESandJOEneeds
EXECUTEonTOM.UPD_TRIGG
Correct
Page3of5
Test:MidTermExamSemester2
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk
(*)indicatesacorrectanswer.
Section10
31.YouneedtodisablealltriggersthatareassociatedwithDMLst
atementsontheDEPARTMENTStable.Whichofthefollowing
commandsshouldyouuse?MarkforReview
(1)Points
ALTERTABLEdepartmentsDISABLEALLTRIGGERS;(*)
ALTERTRIGGERDISABLEALLONdepartments;
ALTERTABLEdepartmentsDISABLETRIGGERS;
DISABLEALLTRIGGERSONdepartments;
ALTERTABLEdepartmentsDROPALLTRIGGERS;
Correct
32.UserAYSEGULsuccessfullycreatesthefollowingtrigger:
CREATETRIGGERloc_trigg
BEFOREUPDATEONaysegul.locationsBEGIN....
AYSEGULnowtriestodroptheLOCATIONStable.Whathappens?
MarkforReview
(1)Points
Anerrormessageisdisplayedbecauseyoucannotdropatablethatis
associatedwithatrigger.
Thetableisdroppedandthetriggerisdisabled.
Thetriggerisdroppedbutthetableisnotdropped.
Boththetableandthetriggeraredropped.(*)
Noneoftheabove.
Correct
33.Thedatabaseadministratorwantstowritealogrecordeverytime
anOracleServererroroccursinanyuser'ssession.TheDBAcreatesthe
followingtrigger:
CREATETRIGGERlog_errs_triggLineA
BEGIN
INSERTINTOerrlog_tableVALUES(...);END;
WhatshouldtheDBAcodeatLineA?MarkforReview
(1)Points
AFTERERRORONDATABASE
AFTERSERVERERRORONDATABASE
AFTERSERVERERRORONSCHEMA
AFTERSERVERERRORONDATABASE(*)
AFTERORACLEERRORONSCHEMA
Correct
34.Youwanttopreventanyobjectsinyourschemafrombeingaltered
ordropped.Youdecidetocreatethefollowingtrigger:
CREATETRIGGERstop_ad_triggLineA
BEGIN
RAISE_APPLICATION_ERROR(20203,'InvalidOperation');END;
WhatshouldyoucodeatLineA?MarkforReview
(1)Points
AFTERALTERORDROPONSCHEMA
INSTEADOFALTERORDROPONSCHEMA
BEFOREALTERORDROPONSCHEMA(*)
BEFOREALTER,DROPONSCHEMA
AFTERALTER,DROPONSCHEMA
Correct
35.Examinethiscode:CREATETRIGGERde_trigg
LineABEGIN...
WhichofthefollowingareNOTvalidatLineA?(Choosetwo.)Mark
forReview
(1)Points
(Chooseallcorrectanswers)
AFTERLOGOFFONSCHEMA(*)
AFTERLOGONONSCHEMA
BEFORELOGOFFONSCHEMA
BEFOREDISCONNECTONSCHEMA(*)
AFTERSERVERERRORONSCHEMA
Correct
36.WhichofthefollowingstatementscouldcauseaDDLtriggerto
fire?MarkforReview
(1)Points
DROPTABLEemployees;
ALTERTABLEdepartmentsADD(budgetNUMBER(8,2));
CREATETABLEnewempASSELECT*FROMemployees;
TRUNCATETABLElocations;
Alloftheabove(*)
Correct
37.Examinethiscode:CREATETRIGGERnew_trigg
AFTERCREATEONreserved_wordBEGIN...
Whichofthefollowingcanbeusedinplaceofreserved_word?(Choose
two
.)
MarkforReview
(1)Points
(Chooseallcorrectanswers)
TABLE
SCHEMA(*)
USER
DATABASE(*)
TABLEemployees
Correct
38.Whichkindsoftriggercancauseamutatingtableproblem?
(Choosetwo.)MarkforReview
(1)Points
(Chooseallcorrectanswers)
BEFOREUPDATErowtriggers(*)
DDLtriggers
AFTERDELETErowtriggers(*)
DatabaseEventtriggers
INSTEADOFtriggers
Correct
39.Examinethefollowingcode:CREATETRIGGERemp_trigg
AFTERUPDATEOFsalaryONemployeesFOREACHROW
DECLARE
v_countNUMBER;BEGIN
LineAEND;
WhichofthefollowingstatementsisNOTallowedatLineA?Markfor
Review
(1)Points
SELECTcount(*)INTOv_countFROMdepartments;
UPDATEemployeesSETjob_id='IT_PROG'WHEREemployee_id
=:OLD.employee_id;
SELECTcount(*)INTOv_countFROMemployees;(*)
DBMS_OUTPUT.PUT_LINE('Asalarywasupdated');
None.Alloftheaboveareallowed.
Correct
40.Whatiswrongwiththefollowingcode?CREATEORREPLACE
TRIGGERloc_triggBEFOREDELETEONlocations
BEGIN
RAISE_APPLICATION_ERROR(20201,'Invaliddelete');
ROLLBACK;
END;
MarkforReview
(1)Points
Thelastlineshouldbe:
ENDloc_trigg;
YoucannotuseRAISE_APPLICATION_ERRORinsideatrigger.
Thesecondlineshouldbe:
BEFOREDELETEOFlocations
YoucannotuseROLLBACKinsideatrigger.
(*)
Nothingiswrong,thistriggerwillcompileandexecutesuccessfully.
Correct
Page4of5
Test:MidTermExamSemester2
Reviewyouranswers,feedback,andquestionscoresbelow.Anasterisk
(*)indicatesacorrectanswer.
Section10
41.Whatiswrongwiththefollowingcode?CREATETRIGGER
dept_trigg
BEFOREUPDATEOFdepartment_nameONdepartmentsBEGIN
DBMS_OUTPUT.PUT_LINE(:NEW.department_name);END;
MarkforReview
(1)Points
Youcannotuse:NEWinaBEFOREtrigger,onlyinanAFTERtrigger.
Youcannotuse:NEWor:OLDinastatementtrigger.(*)
YoucannotuseDBMS_OUTPUT.PUT_LINEinsideatrigger.
Thesecondlineshouldbe:
BEFOREUPDATEONdepartments.department_name
Incorrect.RefertoSection10.
42.Youneedtocreateatriggerthatwillfirewheneveranemployee'ss
alaryorjob_idisupdated,butnotwhenanyothercolumnofthe
EMPLOYEEStableisupdated.Whichofthefollowingisthecorrect
syntaxtodothis?
MarkforReview
(1)Points
CREATETRIGGERemp_upd_trigg
AFTERUPDATEONemployees(salary,job_id)
BEGIN...
CREATETRIGGERemp_upd_trigg
AFTERUPDATEOFsalary,job_idONemployeesBEGIN...
(*)
CREATETRIGGERemp_upd_trigg
AFTERUPDATEOF(salary,job_id)ONemployees
BEGIN...
CREATETRIGGERemp_upd_trigg
AFTERUPDATEOFsalaryORjob_idONemployees
BEGIN...
Correct
43.Thefollowingcodewillsuccessfullycreateemp_trigg:Trueor
False?
CREATEORREPLACETRIGGERemp_triggBEFOREDELETEOF
salaryONemployeesBEGIN
RAISE_APPLICATION_ERROR(20202,'Deletingsalaryisnot
allowed')
;
END;
MarkforReview
(1)Points
True
False(*)
Correct
44.Whattypeofdatabaseobjectwouldyoucreatetowriteanauditing
recordautomaticallyeverytimeauserconnectstothedatabase?Mark
forR
eview
(1)Points
Aprocedure
Acomplexview
Atrigger(*)
Afunction
Apackage
Correct
45.Thefollowingobjectshavebeencreatedinauser'sschema:
afunctionFUNC1
ApackagePACK1whichcontainsapublicprocedurePACKPROCand
aprivatefunctionPACKFUNC
atriggerTRIGG1.
TheprocedureandfunctionseachacceptasingleINparameteroftype
NUMBER,andthefunctionsreturnBOOLEANs.Whichofthe
followingcallstotheseobjects(fromananonymousblock)arecorrect?
(Choosetwo.)Mar
kforReview
(1)Points
(Chooseallcorrectanswers)
pack1.packproc(25);(*)
SELECTfunc1(100)FROMdual;
trigg1;
IFpack1.packfunc(40)THEN...
IFfunc1(75)THEN...(*)
Correct
46.Youcanuseatriggertopreventrowsfrombeingdeletedfromthe
EMPLOYEEStableonMondays.TrueorFalse?MarkforReview
(1)Points
True(*)
False
Correct
47.Whichofthefollowingaregoodguidelinestofollowwhencreating
adatabasetrigger?(Choosetwo.)MarkforReview
(1)Points
(Chooseallcorrectanswers)
Wherepossible,useatriggertoenforceaforeignkeyconstraint.
Usetriggerstooverrideprivilegecheckingandviewotherusers'
privatetables.
Donotuseatriggertoreplaceorduplicatesomethingwhichthe
OracleServerdoesautomatically.(*)
UsetriggerstopreventunauthorizedusersfromSELECTing
confidentialdata.
Donotcreateatriggerthatautomaticallyfiresanothertrigger.(*)
Correct
48.WhichofthefollowingareNOTstoredinsidethedatabase?
(Choosetwo.)MarkforReview
(1)Points
(Chooseallcorrectanswers)
APL/SQLpackagespecification
Adatabasetrigger
Ananonymousblock(*)
Anapplicationtrigger(*)
Asequence
Correct
49.Abusinessrulestatesthatanemployee'ssalarycannotbegreater
than99,999.99orlessthan0.Thebestwaytoenforcethisruleisby
using:MarkforReview
(1)Points
AdatatypeofNUMBER(7,2)fortheSALARYcolumn
Adatabasetrigger
Acheckconstraint(*)
Anapplicationtrigger
Aview
Correct
50.Whichofthefollowingbestdescribesadatabasetrigger?Markfor
Review
(1)Points
Asubprogramthatcheckswhetherauserhastypedthecorrect
passwordtologontothedatabase.
APL/SQLsubprogramthatexecutesautomaticallywheneveran
associated
databaseeventoccurs.(*)
APL/SQLsubprogramthatalwaysreturnsexactlyonevalue.
Asubprogramthatisinvokedexplicitlybythecallingapplication.A
PL/SQLsubprogramthatinsertsrowsintoaloggingtable.
Correct
Test: Mid Term Exam Semester 1 - Part I
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
True (*)
False
Correct
5. Identify which of the following assignment statements are valid.
(Choose three.) Mark for Review
(1) Points
(Choose all correct answers)
v_last_name := Chandra;
v_blackout_date := '31-DEC-2006'; (*)
v_population := 333444; (*)
v_music_type := 'ROCK'; (*)
Correct
Page 1 of 10
Test: Mid Term Exam Semester 1 - Part I
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Mid Term Exam Semester 1 - Part 1
6. When nested blocks are used, which blocks can or must be labeled?
Mark for Review
(1)Points
The inner block must be labeled, the outer block can be labeled.
Both blocks must be labeled
Nested blocks cannot be labeled
The outer block must be labeled if it is to be referred to in the
inner block. (*)
Correct
END;
Mark for Review
(1)Points
My
My name (*)
My name is
My name is Zeynep
Correct
9. An exception occurs within the inner block of two nested blocks. The
inner block does not have an EXCEPTION section. What always happens? Mark
for Review
(1) Points
Both blocks fail and an error message is displayed by the calling
environment
The exception is propagated to the outer block (*)
Oracle automatically tries to re-execute the inner block
The user's database session is automatically disconnected
Correct
10. When an exception occurs within a PL/SQL block, the remaining
statements in the executable section of the block are skipped. True or
False? Mark for Review
(1)Points
True (*)
False
Correct
Page 2 of 10
LOB (*)
Correct
14. A variable is declared as: DECLARE
v_holdit employees.last_name%TYPE;
BEGIN ...
Which of the following is a correct use of the INTO clause? Mark for
Review
(1) Points
SELECT *
INTO v_holdit
FROM employees;
SELECT last_name
INTO v_holdit
FROM employees;
SELECT last_name
INTO v_holdit
FROM employees
WHERE employee_id=100;
(*)
SELECT salary
INTO v_holdit
FROM employees
WHERE employee_id=100;
Correct
SELECT v_salary
INTO salary
FROM employees
WHERE employee_id=100;
SELECT salary
FROM employees
INTO v_salary;
SELECT salary
FROM employees
WHERE employee_id=100
INTO v_salary;
Correct
17. Which of the following is NOT a good guideline for retrieving data
in PL/SQL? Mark for Review
(1)Points
Declare the receiving variables using %TYPE
The WHERE clause is optional in nearly all cases. (*)
Specify the same number of variables in the INTO clause as database
columns in the SELECT clause.
THE SELECT statement should fetch exactly one row.
Correct
18. Which one of these SQL statements can be directly included in a
PL/SQL executable block? Mark for Review
(1) Points
DELETE FROM employees
WHERE department_id=60;
(*)
SELECT salary FROM employees
WHERE department_id=60;
CREATE TABLE new_emps (last_name VARCHAR2(10), first_name
VARCHAR2(10));
DROP TABLE locations;
Correct
19. Assume there are 5 employees in Department 10. What happens when the
following statement is executed?
UPDATE employees
SET salary=salary*1.1;
Mark for Review
(1)Points
All employees get a 10% salary increase. (*)
No rows are modified because you did not specify "WHERE
department_id=10"
A TOO_MANY_ROWS exception is raised.
An error message is displayed because you must use the INTO clause to
hold the new salary.
Correct
20. A PL/SQL block includes the following statement: SELECT last_name
INTO v_last_name
FROM employees
WHERE employee_id=100;
DECLARE (*)
BEGIN
EXCEPTION (*)
END;
Correct
23. Every PL/SQL anonymous block must start with the keyword DECLARE.
True or False? Mark for Review
(1)Points
True
False (*)
Correct
24. What kind of block is defined by the following PL/SQL code? BEGIN
DBMS_OUTPUT.PUT_LINE('My first quiz');
END;
Mark for Review
(1)Points
procedure
subroutine
function
anonymous (*)
Correct
25. Errors are handled in the Exception part of the PL/SQL block. True
or False? Mark for Review
(1)Points
True (*)
False
Correct
Page 5 of 10
Test: Mid Term Exam Semester 1 - Part I
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Mid Term Exam Semester 1 - Part 1
26.Which PL/SQL block type must return a value? Mark for Review
(1)Points
Anonymous
Function (*)
Procedure
Correct
27. Which keywords must be included in every PL/SQL block? (Choose two.)
Mark for Review
(1) Points
(Choose all correct answers)
DECLARE
END; (*)
EXCEPTION
BEGIN (*)
DBMS_OUTPUT.PUT_LINE
Correct
28. What is the purpose of using DBMS_OUTPUT.PUT_LINE in a PL/SQL block?
Mark for Review
(1)Points
To perform conditional tests
To allow a set of statements to be executed repeatedly
To display results to check if our code is working correctly (*)
To store new rows in the database
Correct
29. Which of the following tools can NOT be used to develop and test
PL/SQL code? Mark for Review
(1)Points
Oracle Jdeveloper
Oracle Application Express
Oracle JSQL (*)
Oracle iSQL*Plus
Correct
30.Which of the following declarations is invalid? Mark for Review
(1)Points
v_count PLS_INTEGER:=0;
college_name VARCHAR2(20):='Harvard';
v_pages CONSTANT NUMBER; (*)
v_start_date DATE := sysdate+1;
Correct
Page 6 of 10
Test: Mid Term Exam Semester 1 - Part I
Review your answers, feedback, and question scores below. An asterisk (*)
indicates a correct answer.
Correct
34. The following anonymous block of code is run: BEGIN
INSERT INTO countries (id, name)
VALUES ('XA', 'Xanadu');
SAVEPOINT XA;
INSERT INTO countries (id, name)
VALUES ('NV','Neverland');
COMMIT;
ROLLBACK TO XA;
END;
What happens when the block of code finishes?
Mark for Review
(1)Points
No data is inserted and no errors occur.
No data is inserted and an error occurs
Two rows are inserted and no errors occur.
Two rows are inserted and an error occurs. (*)
Incorrect. Refer to Section 3.
35. Examine the following code:
1DECLARE
2x NUMBER;
3BEGIN
4x:= '300';
5END;
Explicit (*)
Implicit
TO_CHAR
Correct
38. If today's date is 14th June 2007, which statement will correctly
convert today's date to the value: June 14, 2007 ? Mark for Review
(1)Points
TO_CHAR(sysdate)
TO_DATE(sysdate)
TO_DATE(sysdate,'Month DD, YYYY')
TO_CHAR(sysdate, 'Month DD, YYYY') (*)
Correct
39. Single row character functions are valid SQL functions in PL/SQL.
True or False? Mark for Review
(1)Points
True (*)
False
Correct
40. What is wrong with this assignment statement? myvar := 'To be or not
to be';
'That is the question';
Mark for Review
(1)Points
An assignment statement must be a single line of code
Nothing is wrong, the statement is fine
(1)Points
True
False (*)
Correct
43. Examine the following code. What is the final value of V_MYVAR ?
DECLARE
v_myvar NUMBER;
BEGIN
v_myvar := 1 + 2 * 3; v_myvar := v_myvar * 2;
END;
Mark for Review
(1)Points
81
49
14 (*)
18
Correct
44. TO_NUMBER, TO_CHAR, and TO_DATE are all examples of: Mark for Review
(1)Points
Implicit conversion functions
Explicit conversion functions (*)
Character functions
Operators
Correct
Proprietary
Correct
48. Reserved words can be used as identifiers. True or False? Mark for
Review
(1)Points
True
False (*)
Correct
49. Delimiters are _____ that have special meaning to the Oracle
database. Mark for Review
(1)Points
identifiers
variables
symbols (*)
Correct
50. Which of the following are valid identifiers? (Choose two.) Mark for
Review
(1) Points
(Choose all correct answers)
yesterday (*)
yesterday's date
number_of_students_in_the_class
v$testresult (*)
#students
Correct
User-defined integrity
Column integrity
False (*)
Incorrect. Refer to Section 11 Lesson 1.
3. If a primary key is a set of columns then one column must be null. True or False? Mark for Review
(1) Points
True
False (*)
Correct
4. A table must have a primary key. True or False? Mark for Review
(1) Points
True
False (*)
One or more columns in a table that uniquely identifies each row in that table
A set of columns in one table that uniquely identifies each row in another table (*)
Tables
Unique Identifiers in the ER diagram become __________ and relationships become ____________.
Mark for Review
(1) Points
Foreign keys, Primary keys
False (*)
Correct
10. Many to many relationships are implemented via a structure called a: ________________ Mark for
Review
(1) Points
Supertype
Intersection Entity
Subtype
Correct
Section 11 11. When mapping supertypes, relationships at the supertype level transform as usual.
Relationships at subtype level are implemented as foreign keys, but the foreign key columns all become
mandatory. True or False? Mark for Review
(1) Points
True
False (*)
Correct
Section 12 12. What command can be used to create a new row in a table in the database? Mark for
Review
(1) Points
CREATE
NEW
ADD
INSERT (*)
Incorrect. Refer to Section 12 Lesson 1.
13. What command will return data from the database to you? Mark for Review
(1) Points
FETCH
GET
SELECT (*)
RETURN
Incorrect. Refer to Section 12 Lesson 1.
14. The DESCRIBE command returns all rows from a table. True or False? Mark for Review
(1) Points
True
False (*)
Correct.
15. The SQL statement ALTER TABLE EMPLOYEES DELETE COLUMN SALARY is a valid statement.
True or False? Mark for Review
(1) Points
True
False (*)
Correct.
16. Once you have created a table, it is not possible to alter the definition of it. If you need to add a new
column you must delete the table definition and create a new, correct table. True or False? Mark for
Review
(1) Points
True
False (*)
Correct.
Section 13 17. Systems are always just rolled out as soon as the programming phase is finished. No
further work is required once the development is finished. True or False? Mark for Review
(1) Points
True
False (*)
Incorrect. Refer to Section 13 Lesson 1.
18. In the analysis phase the tables are created and populated with test data. True or False? Mark for
Review
(1) Points
True
False (*)
Correct.
Section 15 19. Which statement best describes how arithmetic expressions are handled? Mark for
Review
(1) Points
Addition operations are handled before any other operations.
Multiplication and subtraction operations are handled before any other operations.
Multiplication and addition operations are handled before subtraction and division operations.
Division and multiplication operations are handled before subtraction and addition operations. (*)
Correct.
20. When listing columns in the SELECT list, what should you use to separate the columns? Mark for
Review
(1) Points
Commas (*)
Semicolons
Dashes
Underscores
Correct.
Section 15 21. In which clause of a SELECT statement would you specify the name of the table or tables
being queried? Mark for Review
(1) Points
The FROM clause (*)
Any of the above options, you can list tables wherever you want to in a SELECT statement.
Correct.
22. What would you use in the SELECT clause to return all the columns in the table? Mark for Review
(1) Points
An asterisk (*) (*)
To delete data
Correct.
24. In a SQL statement, which clause specifies one or more columns to be returned by the query? Mark
for Review
(1) Points
SELECT (*)
FROM
WHERE
Any of the above options, you can list columns wherever you want to in a SELECT statement.
Incorrect. See Section 15 Lesson 1.
Section 16 25. The Concatenation Operator does which of the following? Mark for Review
(1) Points
Links rows of data together inside the database.
Links two or more columns or literals to form a single output column (*)
Separates columns.
Correct.
26. You need to display employees whose salary is in the range of 30000 and 50000. Which comparison
LIKE
BETWEEN...AND... (*)
IS NULL
Correct.
27. Where in a SQL statement can you not use arithmetic operators? Mark for Review
(1) Points
SELECT
FROM (*)
WHERE
NONE
Incorrect. See Section 16 Lesson 1.
28. You need to display all the rows in the EMPLOYEES table that contain a null value in the
DEPARTMENT_ID column. Which comparison operator should you use? Mark for Review
(1) Points
"= NULL"
NULL!
ISNULL
IS NULL (*)
Incorrect. See Section 16 Lesson 1.
29. You need to display employees whose salary is in the range of 10000 through 25000 for employees in
department 50 . What does the WHERE clause look like? Mark for Review
(1) Points
WHERE department_id < 50 AND salary BETWEEN 10000 AND 25000 WHERE department_id > 50
AND salary BETWEEN 10000 AND 25000
WHERE department_id = 50
AND salary BETWEEN 25001 AND 10001
WHERE department_id = 50
AND salary BETWEEN 25000 AND 10000
(*)
Correct.
30. You need to display only unique combinations of the LAST_NAME and MANAGER_ID columns in the
EMPLOYEES table. Which keyword should you include in the SELECT clause? Mark for Review
(1) Points
ONLY
UNIQUEONE
DISTINCT (*)
DISTINCTROW
Incorrect. See Section 16 Lesson 1.
Section 16 31. Which of the following commands will display the last name concatenated with the job ID
from the employees table, separated by a comma and space, and label the resulting column "Employee
and Title"? Mark for Review
(1) Points
SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM employees;
SELECT last_name||', '|| job_id "Employee and Title" FROM employees; (*)
SELECT " last name" ||', '|| "job_id" + "Employee and Title" FROM emp;
return the employee last name and department number for employee number 176, which of the following
SQL statements should you use?
Name Type Length
EMPLOYEE_ID NUMBER 22
FIRST_NAME VARCHAR2 20
LAST_NAME VARCHAR2 25
EMAIL VARCHAR2 25
PHONE_NUMBER VARCHAR2 20
SALARY NUMBER 22
COMMISSION_PCT NUMBER 22
MANAGER_ID NUMBER 22
DEPARTMENT_ID NUMBER 22
Mark for Review
(1) Points
SELECT last_name, department_id
FROM employees
WHERE employee_id = 176;
(*)
IN
BETWEEN
LIKE (*)
Correct.
34. You need to display all the employees whose last name starts with the letters Sm . Which WHERE
clause should you use? Mark for Review
(1) Points
WHERE last_name LIKE 'Sm%' (*)
When no attritibutes are mutually independant and fully independent on the primary key.
When no attritibutes are mutually independent and all are fully dependent on the primary key.
Maybe it could stop us having to calculate someone's age every time we need it
Sometimes
(1) Points
Display rows based on a range of values.
The ORDER BY clause can only contain columns that are included in the SELECT list.
The ORDER BY clause should immediately precede the FROM clause in a SELECT statement
Correct.
Section 17 41. The ORDER BY clause always comes last. True or False? Mark for Review
(1) Points
True (*)
False
Incorrect. See Section 17 Lesson 1.
42. Which of the following are TRUE regarding the logical AND operator? Mark for Review
(1) Points
TRUE AND TRUE return FALSE
The OR and AND conditions have the same precedence and will be evaluated from left to right
The OR and AND conditions have the same precedence and will be evaluated from right to left
Correct.
44. Evaluate this SQL statement:
SELECT product_id, product_name, price
FROM products
ORDER BY product_name, price;
What occurs when the statement is executed?
Mark for Review
(1) Points
The results are sorted numerically only.
50
25 (*)
10
250 (*)
Correct.
46. Evaluate this SELECT statement:
SELECT employee_id, last_name, first_name, salary 'Yearly Salary'
FROM employees
WHERE salary IS NOT NULL
ORDER BY last_name, 3;
Which clause contains an error?
Mark for Review
(1) Points
SELECT employee_id, last_name, first_name, salary 'Yearly Salary' (*)
FROM employees
ORDER BY last_name, 3;
Correct.
47. Evaluate this SELECT statement:
SELECT first_name, last_name, email
FROM employees
ORDER BY last_name;
Which statement is true?
Mark for Review
(1) Points
The rows will not be sorted.
The rows will be sorted in reverse alphabetical order by the LAST_NAME values.
The rows will be sorted alphabetically by the FIRST_NAME and then the LAST_NAME values
Correct.
48. Evaluate this SQL statement:
SELECT e.employee_id, e.last_name, e.first_name, m.manager_id
FROM employees e, employees m
ORDER BY e.last_name, e.first_name
WHERE e.employee_id = m.manager_id;
This statement fails when executed. Which change will correct the problem?
PLAYERS TABLE:
LAST_NAME VARCHAR2 (20)
FIRST_NAME VARCHAR2 (20)
SALARY NUMBER(8,2)
TEAM_ID NUMBER(4)
MANAGER_ID NUMBER(9)
POSITION_ID NUMBER(4)
You must display the player name, team id, and salary for players whose salary is in the range from
25000 through 100000 and whose team id is in the range of 1200 through 1500. The results must be
sorted by team id from lowest to highest and then further sorted by salary from highest to lowest. Which
statement should you use to display the desired result?
Mark for Review
(1) Points
SELECT last_name, first_name, team_id, salary
FROM players
WHERE (salary > 25000 OR salary < 100000) AND team_id BETWEEN 1200 AND 1500 ORDER BY
team_id, salary; SELECT last_name, first_name, team_id, salary FROM players WHERE salary
BETWEEN 25000 AND 100000 AND team_id BETWEEN 1200 AND 1500 ORDER BY team_id, salary
DESC; (*) SELECT last_name, first_name, team_id, salary FROM players WHERE salary > 24999.99
AND salary < 100000
AND team_id BETWEEN 1200 AND 1500
ORDER BY team_id ASC, salary DESC;
2. After a cursor has been closed, it can be opened again in the same PL/SQL block.
True or False? Mark for Review
(1) Points
True (*)
False
Correct
3. Which of these is NOT a valid cursor declaration? Mark for Review
(1) Points
CURSOR emp_curs IS
SELECT salary
FROM employees
ORDER BY salary DESC;
CURSOR emp_curs IS
SELECT salary
FROM employees
WHERE last_name LIKE 'S%';
CURSOR emp_dept_curs IS
SELECT e.salary, d.department_name
FROM employees e, departments d
WHERE e.department_id = d.department_id;
CURSOR emp_curs IS
SELECT salary INTO v_salary
FROM employees;
(*)
Correct
4. Which of these constructs can be used to fetch multiple rows from a cursor's
active set? Mark for Review
(1) Points
A CASE statement
An IF .... ELSE statement
A basic loop which includes FETCH and EXIT WHEN statements (*)
A basic loop which includes OPEN, FETCH and CLOSE statements
Incorrect. Refer to Section 5.
5. The employees table contains 20 rows. What will happen when the following code is
executed?
DECLARE
CURSOR emp_curs IS SELECT job_id FROM employees; v_job_id employees.job_id%TYPE;
BEGIN
OPEN emp_curs;
LOOP
FETCH emp_curs INTO v_job_id;
DBMS_OUTPUT.PUT_LINE(v_job_id);
EXIT WHEN emp_curs%NOTFOUND;
END LOOP;
CLOSE emp_curs;
END;
Mark for Review
(1) Points
20 job_ids will be displayed.
The block will fail and an error message will be displayed.
21 rows of output will be displayed; the first job_id will be displayed twice.
21 rows of output will be displayed; the last job_id will be displayed twice. (*)
Correct
Mark for
Review
Mark for
Review
Store all the numbers from 1 to 144 in a table, then fetch and display them using a cursor.
Create a function which accepts two numbers as IN parameters and returns their product. Invoke
the function 144 times.
Write an anonymous block which contains 144 calls to DBMS_OUTPUT, each looking like:
DBMS_OUTPUT.PUT_LINE('7 x 9 = 63');
Correct
11. Examine the following code fragment:
DECLARE
CURSOR emp_curs IS
SELECT first_name, last_name FROM employees; v_emp_rec emp_curs%ROWTYPE;
BEGIN
...
FETCH emp_curs INTO v_emp_rec;
DBMS_OUTPUT.PUT_LINE(... Point A ...);
...
To display the fetched last name, what should you code at Point A?
Mark for Review
(1) Points
v_emp_rec.last_name (*)
v_emp_rec(last_name)
v_emp_rec
last_name
None of the above
Correct
12. Assume that you have declared a cursor called C_EMP. Which of the following
statements about C_EMP is correct? (Choose two.) Mark for Review
(1) Points (Choose all correct answers)
You can use c_emp%NOTFOUND to exit a loop. (*)
You can fetch rows when c_emp%ISOPEN evaluates to FALSE.
You can use c_emp%ROWCOUNT to return the number of rows returned by the cursor so far.
(*)
Correct
13. The following cursor has been declared:
CURSOR emp_curs IS
SELECT first_name, last_name, job_id, salary
FROM employees;
Which of the following correctly declares a composite record with the same structure as the
cursor?
Mark for Review
(1) Points
emp_rec emp_rec%ROWTYPE;
emp_rec emp_curs%TYPE;
emp_rec emp_curs%ROWTYPE; (*)
emp_rec cursor%ROWTYPE;
Incorrect. Refer to Section 5.
14. Which of the following cursor attributes evaluates to TRUE if the cursor is
open? Mark for Review
(1) Points
%ISOPEN (*)
%NOTFOUND
%FOUND
%ROWCOUNT
Correct
15. Which of the following cursor attributes is set to the total number of rows
returned so far?
(1) Points
%ISOPEN
%NOTFOUND
%FOUND
Mark for
Review
%ROWCOUNT (*)
Correct
16. The employees table contains 11 columns. The following block declares a cursor and a record
based on the cursor:
DECLARE
CURSOR emp_curs IS
SELECT * FROM employees;
v_emp_rec emp_curs%ROWTYPE;
A twelfth column is now added to the employees table. Which of the following statements is
true?
END;
Mark for Review
(1) Points
The cursor DEPT_CURS has not been opened.
The implicitly declared record DEPT_REC cannot be referenced outside the cursor FOR loop.
(*)
You cannot use %ROWCOUNT with a cursor FOR loop.
The cursor DEPT_CURS has not been closed.
Nothing is wrong, this code will execute successfully.
Correct
19. When using a cursor FOR loop, OPEN, CLOSE and FETCH statements should
not be explicitly coded. True or False?
(1) Points
True (*)
Mark for
Review
False
Correct
20. Examine the following declaration of a cursor with a parameter. What should be
coded at Point A? DECLARE
CURSOR emp_curs(-- Point A --) IS
SELECT * FROM employees
WHERE job_id = p_job_id;
Mark for Review
(1) Points
p_job_id
ST_CLERK'
p_job_id VARCHAR2(25)
p_job_id VARCHAR2 (*)
job_id VARCHAR2
Mark for
Review
WHILE loop
Correct
24. Which one of these tasks is best done using a LOOP statement?
Review
(1) Points
Assigning a letter grade to a numerical score
Mark
for
Calculating and displaying the sum of all integers from 1 to 100 (*)
Testing if a condition is true, false or null
Fetching and displaying an employee's last name from the database
Incorrect. Refer to Section 4.
25. The EXIT statement can be located anywhere inside a basic loop. True or False?
Mark for Review
(1) Points
True (*)
False
Incorrect. Refer to Section 4.
26. A PL/SQL block contains the following code:
v_counter := 1; LOOP
EXIT WHEN v_counter = 5;
v_counter := v_counter + 1;
END LOOP;
What is the value of V_COUNTER after the loop is finished?
Mark for Review
(1) Points
5 (*)
6
1
This is an infinite loop; the loop will never finish.
Correct
27. What will be the value of v_sal_desc after the following code is executed?
DECLARE
v_salary NUMBER(6,2) := NULL;
v_sal_desc VARCHAR2(10);
BEGIN
CASE
WHEN v_salary < 10000 THEN v_sal_desc := 'Low Paid';
WHEN v_salary >= 10000 THEN v_sal_desc := 'High Paid';
END CASE;
END;
Mark for Review
(1) Points
High Paid
Low Paid
Null
The code will fail and return an exception (*)
Correct
28. You want to display a message which depends on the value of v_grade: if v_grade =
'A' display 'Very Good', if v_grade = 'B' then display 'Good', and so on.
DECLARE
v_grade CHAR(1);
BEGIN
CASE v_grade
The next line should be
Mark for Review
(1) Points
WHEN 'A' THEN (*)
WHEN v_grade = 'A' THEN
WHEN 'A' THEN;
IF 'A' THEN
Correct
29. What will be the value of v_result after the following code is executed?
DECLARE
v_grade CHAR(1) := NULL;
v_result VARCHAR2(10);
BEGIN
CASE v_grade
WHEN 'A' THEN v_result := 'Very Good';
WHEN 'F' THEN v_result := 'Poor';
ELSE v_result := 'In Between';
END;
END;
DECLARE
v_grade CHAR(1);
v_result VARCHAR2(10);
BEGIN v_result :=
CASE v_grade
The next line should be
Mark
for
When the controlling condition must be evaluated at the start of each iteration
Correct
36. Which statement best describes when a WHILE loop shouild be used?
Review
(1) Points
When the number of iterations is known
Mark
for
When repeating a sequence of statements until the controlling condition is no longer true
(*)
When assigning a value to a Boolean variable
When testing whether a variable is null
Correct
37. Which of the following blocks produces the same output as this block?
BEGIN
FOR i in 1 .. 3 LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
Mark for Review
(1) Points
DECLARE
i PLS_INTEGER := 0; BEGIN
WHILE i<3 LOOP DBMS_OUTPUT.PUT_LINE(i); i := i + 1;
END LOOP;
END;
DECLARE
i PLS_INTEGER := 0; BEGIN
WHILE i<3 LOOP i := i + 1;
DBMS_OUTPUT.PUT_LINE(i);
END LOOP;
END;
(*)
DECLARE
i PLS_INTEGER := 0; BEGIN
WHILE i<3 LOOP
DBMS_OUTPUT.PUT_LINE(i);
END LOOP; i := i+ 1;
END;
Correct
38. Examine the following code:
DECLARE
v_bool BOOLEAN := FALSE;
v_counter NUMBER(4) := 0;
BEGIN
... Line A
END;
Which of the following is NOT valid at line A?
Mark for Review
(1) Points
WHILE NOT v_boolean LOOP
WHILE v_boolean AND v_counter < 6 LOOP
WHILE v_counter > 8 LOOP
WHILE v_counter IN 1..5 LOOP (*)
Correct
39. In a FOR loop, an implicitly declared counter automatically increases or
decreases with each iteration. True or False?
(1) Points
True (*)
Mark for
Review
False
Correct
40. In a WHILE loop, the statements inside the loop must execute at least once. True
or False?
(1) Points
True
False (*)
Mark for
Review
Mark for
Review
(1) Points
Mark
for
lost' (*)
False
Incorrect. Refer to Section 4.
44. What is the correct form of a compound IF statement? Mark for Review
(1) Points
IF condition
THEN statement1
ELSE statement 2;
IF condition
THEN statement1
ELSE statement 2;
END IF;
IF condition;
THEN statement1;
ELSE statement2;
END IF;
IF condition THEN statement1;
ELSE statement2;
END IF;
(*)
Correct
45. You want to display all locations, and the departments in each location. Examine the
following code:
DECLARE
CURSOR loc_curs IS SELECT * FROM locations;
CURSOR dept_curs(p_loc_id NUMBER) IS
SELECT * FROM departments WHERE location_id = p_loc_id;
BEGIN
FOR loc_rec IN loc_curs LOOP
DBMS_OUTPUT.PUT_LINE(loc_rec.city);
FOR dept_rec IN dept_curs(-- Point A --) LOOP
DBMS_OUTPUT.PUT_LINE(dept_rec.department_name);
END LOOP;
END LOOP;
END;
What should you code at Point A? Mark for Review
(1) Points
p_loc_id
location_id
null
LOOP ... END LOOP;
loc_rec.location_id (*)
Correct
46. Which of the following is a good reason to declare and use multiple cursors in a
Mark for
single PL/SQL block?
Review
(1) Points
Multiple cursors improve performance. They are faster than using a single cursor.
Multiple cursors use less memory than a single cursor.
Multiple cursors allow us to fetch rows from two or more related tables without using a JOIN.
(*)
Multiple cursors are the only way to use cursors with parameters.
Multiple cursors can be opened many times, while a single cursor can be opened only once.
Correct
47. When using multiple nested cursors, what kinds of loops can you use?
for Review
(1) Points
Cursor FOR loops only.
Basic loops only.
WHILE loops only.
None of the above.
All of the above. (*)
Incorrect. Refer to Section 5.
Mark