0% found this document useful (1 vote)
2K views7 pages

Wipro Freshers Training Programme - SAMPLE PL - SQL ASSIGNMENTS

This document provides sample PL/SQL assignments for trainees in Wipro's training program. It includes 9 PL/SQL assignments covering topics like anonymous blocks, procedures and functions, cursors, data types, exceptions handling, and packages. The assignments involve writing PL/SQL code to perform tasks like selecting, inserting, updating, and deleting data from database tables. They also include examples using PL/SQL features like records, cursors, exceptions.

Uploaded by

KunalMalhotra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
2K views7 pages

Wipro Freshers Training Programme - SAMPLE PL - SQL ASSIGNMENTS

This document provides sample PL/SQL assignments for trainees in Wipro's training program. It includes 9 PL/SQL assignments covering topics like anonymous blocks, procedures and functions, cursors, data types, exceptions handling, and packages. The assignments involve writing PL/SQL code to perform tasks like selecting, inserting, updating, and deleting data from database tables. They also include examples using PL/SQL features like records, cursors, exceptions.

Uploaded by

KunalMalhotra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
0

More NextBlog

CreateBlog SignIn

WiproFreshersTraining
Programme
Search

Friday,19August2011

Google+Followers

SAMPLEPL/SQLASSIGNMENTS

IsthisblogHelpfull?

Yes
No
PL/SQL

Vote Showresults

AnonymousBlock

Votessofar:59
Dayslefttovote:21

1.WriteaPL/SQLblockthatselectsthemaximumdepartmentnumberinthedepartmenttableand
storeitinaSQL*PLUSvariable.Andprinttheresultstoscreen.

Shareit

2.CreateaPL/SQLblocktoinsertanewdepartmentnumberintotheDepartmentstable.Use
maximumdeptnumberfetchedfromaboveandadds10toit.UseSQL*PLUSsubstitutionvariablefor
departmentname.LeavethelocationASnull.
3.CreateaPL/SQLblocktoupdatethelocationforanexistingdepartment.Usesubstitutionvariable
fordeptno.anddeptlocation.
4.CreateaPL/SQLBlocktodeletethedepartmentcreatedinexercise2.Printtothescreenthe
numberofrowsaffected.
5.1.WriteaPL/SQLblockwhichacceptsemployeename,basicandshoulddisplay
Employeename,PFandnetsalary.
HRA=31%ofbasicsalary
DA=15%ofbasicsalary
Netsalary=basic+HRA+DAPF
Ifthebasicislessthan3000PFis5%ofbasicsalary.
Ifthebasicisbetween3000and5000PFis7%ofbasicsalary.
Ifthebasicisbetween5000and8000PFis8%ofbasicsalary.
6.WriteaPL/SQLblocktofindthesalarygradeofthespecifiedemployee.
Ifgradeis1displaytheemployeeisjuniorengineer
Ifgradeis2displaytheemployeeisengineer
Ifgradeis3displaytheemployeeisleadengineer
Ifgradeis4displaytheemployeeisManager
Ifgradeis5displaytheemployeeisProjectmanager
(Usecaseexpression)

SharethisonFacebook
Tweetthis
Viewstats
(NEW)Appointmentgadget>>

AndroidApplicationDeveloper

LearnJavaforAndroidDevelopment

BlogArchive

2014(1)
2013(1)
2012(5)
2011(15)
September(1)
August(14)
FRPUNIXSampleQuestionswith
Answers
FRPQuestionsforpractice
FRPUNIXPAPER2SAMPLE
QUESTIONWITHANSWERS
CProgramsduringtrng
SamplePRPQuestions
FRPSAMPLEQUESTIONSWITH
ANSWERS
SampleCProgramsforFRP
SAMPLEPL/SQLASSIGNMENTS

7.WrtieaPL/SQLblocktoawardanemployeewiththebonus.
Bonusis15%ofcommissiondrawnbytheemployee.Iftheemployeedoesnotearnanycommission
thendisplayamessagethatemployeedoesnotearnanycommission.Otherwiseaddbonustothe
salaryoftheemployee.Theblockshouldacceptaninputfortheemployeenumber.

8.WriteaPL/SQLblockwhichdisplaysthedepartmentname,totalnoofemployeesinthe
department,avgsalaryoftheemployeesinthedepartmentforallthedepartmentsfromdepartment
10todepartment40intheDepttable.Ifnoemployeesareworkinginthedepartment,thendisplaya
messagethatnoemplyeesareworkinginthatdepartment.
9.WriteaPL/SQLblockwhichacceptsemployeenumberandfindstheaveragesalaryofthe
employeesworkinginthedepartmentwherethatemployeeworks.

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

SAMPLESQLASSIGNMENTSDURING
TRAINING
TrainingProcessFlowinWipro
FRPCANDDataStructureQUESTIONS
JAVAPRPIMPORTANTQUESTIONS
CPROGRAMTODRAWTHEMAPOF
INDIAADVANCEHAP...
USdowngradenottoimpactIndianIT
cosincluding...

TotalPageviews

1/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
Ifhissalaryismorethantheaveragesalaryofhisdepartment,thendisplaymessagethat
employeessalaryismorethanaveragesalaryelsedisplayemployeessalaryislessthanaverage
salary

4 6 7 8 5

Proceduresandfunctions
1.Createaprocedurethatdeletesrowsfromtheemp
table.Itshouldaccept1parameter,jobonlydeletethe
employeeswiththatjob.Displayhowmanyemployeeswere
deleted.WriteaPL/SQLblocktoinvoketheprocedure.
2.Changetheaboveproceduresothatitreturnsthenumberof
employeesremovedviaanOUTparameter.WriteaPL/SQLblock
toinvoketheprocedureanddisplayhowmanyemployees
Weredeleted.
3.Converttheaboveprogramtoafunction.Insteadofusing
anOUTparameterforthenumberofemployeesdeleted,use
thefunctionsreturnvalue.Writeaprogramtoinvokethe
functionanddisplayhowmanyemployeesweredeleted.
4.Createatablehavingthefollowingstructure
Accounts(Account_id,branch_name,amount_balance)
a.WriteaPL/SQLproceduretoperformwithdrawoperationthatonlypermitsawithdrawalif
theresufficientfundsintheaccount.TheprocedureshouldtakeAccount_idandwithdrawalamount
asinput.
b.Writeaproceduretodepositmoneyintosomeone'saccount.Theprocedureshouldaccept
account_idanddepositamount.
c.Writeaproceduretotransfermoneyfromoneperson'saccounttoanother.Theprocedure
shouldtabletwoaccount_idsoneforgiverandoneforreceiverandtheamounttobetransferred.

CursorsandDataTypesasin3GL
1.WriteaPL/SQLblocktoacceptanemployeenumber.andusearecordvariabletostoretherecord
ofthatemployee.andinsertitintoretired_employeetable.
Retired_employeetablehasthefollowingstructure
Retired_employee(empno,ename,hiredate,leaveDate,salary,mgr_id,deptno).
Settheleavedatetothecurrentdate.
2.WriteaPL/SQLBlocktocreateaPL/SQLtablewhichcanstoregradeandonofemployeeswith
thatgrade.Gettheinformationaboutthegradeandnumberofemployeeswiththatgradeandstore
itinthePL/SQLtable.ThenretrievetheinformationfromthePL/SQLtableanddisplayitonthe
screeninthefollowingway.
Noofemployeeswiththegrade1are3
Noofemployeeswiththegrade2are2
Noofemployeeswiththegrade3are1
Noofemployeeswiththegrade4are2
Noofemployeeswiththegrade5are5

Followers

Jointhissite
withGoogleFriendConnect

Members(5)

Alreadyamember?Signin

Contributors

Administrator
Karthikeyan

Cursors
1.Writeaprogramthatgivesallemployeesindepartment10a
15%payincrease.Displayamessagedisplayinghowmany
Employeeswereawardedtheincrease.
2.WriteaPL/SQLblockandusecursortoretrievethedetailsoftheemployeeswithgrade5.andthen
displayemployeeno,job_id,max_salandmin_salandgradeforalltheseemployees.
3.WriteaPL/SQLblockthatcopiesalldepartmentstoatable
calledold_dept.DonotuseacursorFORloop.Display
howmanyrowswerecopied.
4.DisplaythenamesofemployeeswhoareworkingforDepartment30.
5.WriteaPL/SQLBlockthatmimicsselectingallcolumnsandrows
fromthedepttable.Thereisnoneedtoformattheoutput,

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

2/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
justselectallcolumnsandallrows.UseacursorFORloop.
6.WriteaPL/SQLblocktodisplaythetop6employeeswithrespecttosalariesusingcursors.
7.Useacursortoretrievethedepartmentnumberandthedepartmentnamefromthedepttable.
Passthedepartmentnumbertoanothercursortoretrievefromtheemptablethedetailsof
employeename,job,hiredateandsalaryofalltheemployeeswhoworkinthatdepartment.
8.WriteaprocedureRaise_salarywhichgivesaspecifiedhiketoalltheemployeesworkingina
specifieddepartment.Theprocedureshouldtakedepartmentnumberandpercemtageofhikeas
input.(Useforupdateandwherecurrentof)

ExceptionHandling
1.WriteaPL/SQLblocktoselectthenameoftheemployeewithagivensalaryvalue.
Ifthesalaryenteredreturnsmorethanonerow,Handletheexceptionwithanappropriateexception
handlerandinsertintoSALARY_MESSAGEStablethemessagemorethanoneemployeewitha
salaryof<salary>
Ifthesalaryentereddoesnotreturnanyrows,handletheexception
WithanappropriateexceptionhandlerandandinsertintotheSALARY_MESSAGEStablethe
messagenoemployeewithasalaryof<salary>
Ifthesalaryenteredreturnsonlyonerow,insertintotheSALARY_MESSAGEStable,theemloyees
nameandthesalaryamount.
HandleanyotherexceptionwithanappropriatehandlerandinsertintotheSALARY_MESSAGEStable
themessagesomeothererroroccurred.Testtheblockforavarietyoftestcases.
2.WriteaPL/SQLblocktoremoveaspecifieddepartmentfromthedepartmenttable.Ifthereare
employeesinthatdepartment,printamessagetotheuserthatthedepartmentcannotberemoved.
(Usepragmaexceptioninit)
3.WriteaPL/SQLprogramtoupdatethesalaryandDepartmentnumberintheemployees
tableusingSQL*Plusbindvariables(orinitializedlocalvariablesifyouprefer).Includethefollowing
exceptionhandlingcapabilities:
Define,raiseandhandleanexceptionforsalaryvaluesnotintherangeof800to5000.
Defineandassociate(EXCEPTION_INIT)andexceptionwiththereferentialintegrityconstraint
violatedsystemexception(2291)anduseittohandleattemptstosetthedeptnotoa
valuenotfoundintheDepartmenttable.
Providesimpleerrorhandlingforanyotherexceptions

Packages
Readthefollowingspecification:
DevelopapackagethatwillactasanAPI(ApplicationProgrammingInterface)fortheitemstable.
WeneedtoprotectourdataandwanttoensurenoonewritesanycodethatwilldirectlyAccessthis
table.
Hereisthestructureoftheitemstable:
ColumnDataTypeDescription
item_idNUMBERInternalIDforitem
item_numberVARCHAR2(10)Useritemnumber
descriptionVARCHAR2(30)Itemdescription
statusVARCHAR2(1)[T]estor[L]ive
CostNUMBERStandardcostofitem
Weneedtheitem_idcolumntobeasequentialnumber(use
items_item_id_ssequence)
Thefollowingbusinessrulesmustbeapplied:
Anitemiscreatedasatestitemandwithazerocost.
Aprocedureorfunctionmustbecalledtopromotetheitemfromtest
tolive.Anitemcannotbemadelivewithazerocost.
Onlytestitemscanberemoved
WeneedanAPItoprovidethedeveloperthefollowingfacilities:
Createnewitems

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

3/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
Promoteitemsfromtesttolive
Removeitems
Changeitemcost
AllAPIfunctionsandproceduresshouldworkwiththeitem_id.
Createapackagetoimplementtheabove.Remember,tryand
workouttherequirementsforthepackagefirst.Determineyour
publicandprivateprocedures/functionsandanydatathatmight
Beneeded.

Triggers
1.Tocomplimentthepackagedevelopedinthelastsection,theuser
hascomeupwiththefollowingadditiontothespecification.
Implementtheabovespecificationusingtriggers.
WhenitemsareremovedusingthenewAPIyouprovided,weneedto
ensuretheitemisarchivedinatablecalleditems_archive.
Wealsowantanychangesinitemcosttobeaudited,recordthedetails
ofeachchangeintheauditing_costtable.

2.AnHRsystemhasanemptablethatholdsarowforeachemployeewithinthecompany.Each
recordinthetablehasamanagerfield,(mgr)thatholdstheidfortheemployee'smanager.Writea
triggersothatwhenamanagerrecordisdeleted,themgrfieldofthatmanager'semployeesissetto
NULL.Inotherwords,implementthefollowingSQLstatement:
WHENANEMPLOYEEISDELETED,
UPDATEemployeeSET
mgr=null
WHERE
mgr=employeeidofthedeletedemployee
3.Createoneadditionaltablejob_salaryhavingcolumns
Job_salary(job,min_sal,max_sal)
Andinsertfollowingrecordsintothetable.
('CLERK',800,1300)
('ANALYST',3000,3500)
('SALESMAN',1250,1600)
('MANAGER',2450,2975)
('PRESIDENT',5000,5500)
WriteatriggeronemptablesothatwhenanewemployeerecordisinsertedorupdatedandIfthe
newsalaryhasbeendecreasedordoesnotliewithinthesalaryrangeforthatjoborifmorethan
10%hikeisgiven,thenitshouldraiseexceptionsforthesethreecasesmentionedabove.And
triggershouldbeexecutedforemployeesotherthanthepresident.

4.Writeatriggeronthetablejob_salarysothatwhenarecordisdeletedorupdatedfromthistable,
thetriggershouldfireandhastocheckwhetheremployeeshavingthedeletedjobexist.Ifyes,it
shouldraiseanexception.andifitisupdation,andifthereareemployeesintheemptablewhose
salarydoesnotliewithinthemodifiedrange,thenrestoreoldsalaryranges.

PostedbyKarthikeyan

Recommend this on Google

funny (0)

Reactions:

interesting (1)

cool (0)

27comments:
ParagDeshmukh 26October2013at01:40
any1havingsolutionofthesequestions...?
Reply
Replies
PrasannaSuri 12March2014at18:04
ihavealltheanswithmebuthowcouldisharethemhere

Karthikeyan

12March2014at23:12

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

4/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
[email protected]'llpostitonthiswebsite...
Thanks
Administrator

Karthikeyan

12March2014at23:12

[email protected]'llpostitonthiswebsite...
Thanks
Administrator

PrasannaSuri 13March2014at10:44
HiKarthi,ihavesenttheanswerstothegivenemailaddress.
Plspostthemhere.
Thanks,
Suri

SaravananElangovan 13March2014at17:29
[email protected]

PrasannaSuri 13March2014at17:41
HiSarvanan,
Ihaveforwardedthedocpleasecheck.
Thanks,
Suri

dipankarsaikia 13April2014at21:15
can anyone send me answers only procedures and functions..please mail
me..."[email protected]"ineedyourhelpplease

TammewarSumeeth 23May2014at20:35
Thiscommenthasbeenremovedbytheauthor.

ArpanGupta 27May2014at11:20
HIPrassanna,
[email protected]
thanksinadvance!!

AkhilChadha 10February2015at17:35
[email protected]!!
Reply

BalvirJha 1November2013at23:25
yes...butitisavailableat$10.
Reply

kaustubhchaudhary 20March2014at13:47
[email protected]
Reply

kaustubhchaudhary 20March2014at13:49
hi prasant suri....if u have the answer then please send mi on my email
kaustubh.jeindia@gmailcom
Reply

MhlongoDzonga 25March2014at19:30
[email protected]
Reply

sarathkumar 30March2014at17:49
[email protected]

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

5/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS
Reply

sarathkumar 30March2014at17:55
HiPrasannaidevelopedsomeassignmentsiwanttocheckmyquriescanusendanswersat
[email protected]
Reply

TamilSelvi 12April2014at21:49
hifrnds...
plssendassignmentanswers
Reply

NaveenRai 16April2014at12:16
[email protected].
Reply

PrasannaSuri 16April2014at14:48
Guysanshavebeensenttoalltheemailid'sprovidedhere.
pleaseforwardthemtowhoeverneedit.
Reply

Karthikeyan

16April2014at23:16

HiAll,
Asperyourrequestipostedtheanswersasapost.
Link:http://wiprotraining.blogspot.in/2014/04/sampleplsqlassignmentsanswers.html
Reply
Replies
PrasannaSuri 17April2014at12:10
HiKarthi,
Thanksforpostingtheanswershere.Thiswillhelp.
Reply

Unknown 23May2014at06:30
Veryuseful...Thanksalot:)
Reply

ARITRASADHU 19February2015at11:22
pleasesendmetheanswers
mailid:[email protected]
Reply

reem 20March2015at14:31
pleasesendtheanswers
[email protected]
Reply

vinothkumar 22March2015at19:25
Thiscommenthasbeenremovedbytheauthor.
Reply

vinothkumar 22March2015at19:27
[email protected]
Reply

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

6/7

3/24/2015

WiproFreshersTrainingProgramme:SAMPLEPL/SQLASSIGNMENTS

Enteryourcomment...

Commentas:

Publish

GoogleAccount

Preview

NewerPost

Home

OlderPost

Subscribeto:PostComments(Atom)

Simpletemplate.PoweredbyBlogger.

http://wiprotraining.blogspot.in/2011/08/sampleplsqlassignments.html

7/7

You might also like