Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
7Activity
0 of .
Results for:
No results containing your search query
P. 1
Using Multiple Cursors

Using Multiple Cursors

Ratings: (0)|Views: 480 |Likes:
Published by Catalina Achim

More info:

Published by: Catalina Achim on May 26, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

04/20/2014

pdf

text

original

 
Test:Quiz:UsingMultipleCursors1.AssumethattableBIGDEPTScontains100rows,andtableBIGEMPScontains1000rows,with10employeesineachdepartment.Considerthefollowingcode:DECLARECURSORbigdept_curISSELECT*FROMbigdepts;CURSORbigemp_curISSELECT*FROMbigemps;BEGINFORdept_recINbigdept_curLOOPDBMS_OUTPUT.PUT_LINE(dept_rec.department_name);FORemp_recINbigemp_curLOOPIFemp_rec.department_id=dept_rec.department_idTHENDBMS_OUTPUT.PUT_LINE(emp_rec.last_name);ENDIF;ENDLOOP;ENDLOOP;END;Whyisthiscodeinefficient?MarkforReview(1)PointsItlocksbothtablesunnecessarily.Itisusingtwocursorswhenonecursorisenough.ItisdoingaCartesianProduct,joiningeveryemployeewitheverydepartmentanddisplaying1100linesofoutput.Itreads1000employeerowseverytimeBIGEMP_CURisOPENed,andthenignores990ofthem.(*)ItisusingcursorFORloops,whicharelessefficientthanOPENingandCLOSEingthecursorsexplicitly.Correct2.Examinethefollowingcode:DECLARECURSORregion_curISSELECT*FROMwf_world_regions;v_region_recregion_cur%ROWTYPE;CURSORcountry_cur(p_region_idNUMBER)ISSELECT*FROMwf_countriesWHEREregion_id=p_region_id;v_country_reccountry_cur%ROWTYPE;BEGINOPENregion_cur;LOOPFETCHregion_curINTOv_region_rec;
 
EXITWHENregion_cur%NOTFOUND;DBMS_OUTPUT.PUT_LINE(v_region_rec.region_name);--LineA--LOOPFETCHcountry_curINTOv_country_rec;EXITWHENcountry_cur%NOTFOUND;......WhatwouldyoucodeatLineA?MarkforReview(1)PointsOPENcountry_cur(p_region_id);OPENcountry_cur(wf_world_regions.region_id);OPENcountry_cur(v_region_rec.region_id);(*)OPENcountry_cur(region_cur.region_id);OPENcountry_cur;Correct3.Youwanttoproduceareportwhichdisplayseachdepartmentand(immediatelyaftereachdepartment)alistofemployeeswhoworkinthatdepartment.YoudeclareaDEPARTMENTScursoras:CURSORdept_cursISSELECT*FROMdepartmentsORDERBYdepartment_id;HowcouldyoudeclaretheEMPLOYEEScursor?(Choosetwo).MarkforReview(1)Points(Chooseallcorrectanswers)CURSORemp_cursISSELECT*FROMemployees;CURSORemp_curs(p_dept_idNUMBER)ISSELECT*FROMemployeesWHEREdepartment_id=p_dept_id;(*)CURSORemp_cursIS
 
SELECT*FROMemployeesORDERBYdepartment_id;CURSORemp_curs(p_dept_iddepartments.department_id%TYPE)ISSELECT*FROMemployeesWHEREdepartment_id=p_dept_id;(*)CURSORemp_cursISSELECT*FROMemployeesWHEREdepartment_id=departments.department_id;Incorrect.RefertoSection5Lesson6.4.WhichofthefollowingisagoodreasontousetwocursorsinasinglePL/SQLblock? MarkforReview(1)PointsToallowonecursortobeopenedtwiceatthesametime.Whentwotablesarerelatedtoeachother(oftenbyaforeignkey)andwewanttoproduceamultilevelreportusingdatafrombothtables.(*)ToallowrowstobelockedastheyareFETCHed.TospeeduptheexecutionofthePL/SQLblock.Itistheonlywaytodeclareacursorwithaparameter.Correct5.WhichofthefollowingisNOTallowedwhenusingmultiplecursorswithparameters? MarkforReview(1)PointsYoucannotusecursorFORloops.YoucannotdeclarethecursorsFORUPDATE.Youcannotdeclareacursorbasedonajoin.YoucannotOPENmorethanonecursoratthesametime.

Activity (7)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads
Enis Gemil liked this
Nadira Đogić liked this
shrunash liked this
Frantík Blboun liked this
Run Zhuo Li liked this

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->