Assignment Gtu PLSQL
Assignment Gtu PLSQL
1.Painting
2.Dancing
TotalMarks:_______
2. Customer(Cust_Id,Cust_Name,Cust_Addr,Cust_City,EmailID,Contact_No)
Magazine(Mag_Id,Mag_Name,Unit_Rate,Type_of_subsciption[weekly,monthly,etc.])
Subscription(Cust_Id,Mag_Id,start_date,end_date)
Implement the following
:
A)
1.CreateaViewthatdisplaysCustomername,Magazinenamealongwithitsrate
whichwassubscribedduring01Sept2010to01Feb2011.
2.Findtopthreemagazineshavingthehighestsaleduringlastonemonthoftime.
B)
1.CreateafunctiontoreturnNo.ofcustomersincityGandhinagarwhohavesubscribed
themagazineOutlookafterAugust2010.Ifnosuchcustomerexists,throwauser
definedexceptionwithappropriatemessage.
2.CreateatriggerthatisfiredafteranINSERTstatementisexecutedfortheCustomer
table.Thetriggerwritesthenewcustomerscode,nameandthesysdateinatable
calledCustomer_Log.(createthetableCustomer_Log)
3. Account(ac_no,ac_name,act_type)
Transaction(ac_no,trans_date,tran_type,tran_amount,balance)
Note:Act_typemaybeSforsavingorCforcurrentandtran_typemaybeDfordeposit
orWforwithdrawal.
Implement the following
A)
1.Findoutthosesavingtransactionsthattookplacebetween10thJanuary2011and
20thJanuary2011andhavewithdrawnanamountgreaterthanRs.50,000.
2.CreateaSequencethatcanbeusedtoenternewaccountnumberintotheaccount
table.AddanewrecordintoAccounttableusingthecreatedsequence.
B)
1.Createatriggernotallowinginsertion,deletionorupdationonSaturdayandbefore
8:00AM&after6:00PMonAccounttable.
2.Createapackageforthefollowing:
Createafunctiontoreturnthecurrentbalanceforagivenaccountnumber.
4. Supplier(sid,sname,contactnum)
Parts(pid,pname,color,unitrate)
Catalog(sid,pid,qty)
Implement the following
:
A)
1.FindthetopthreePartsbeenorderedandhavethehighestsaletilldate.
2.Findthosesupplierswhochargemoreforsomepartthattheaveragecostofthatpart.
B)
CreateaPL/SQLblocktoprepareinvoiceinfollowingformat.
Displaytheinvoiceinthefollowingformat.Useparameterizedcursor.
Invoice:::<SuppliersName>
PartIdPartNameQuantityUnitPrice
TotalPrice
Total:_______
5. Sailor(sid,sname,rating(010),DOB)
Boat(bid,bname,color)
Reserve(sid,bid,date)
Employee_master(EmpCode,Emp_Name,Dept_Id,Emp_Address,DOB,Basic_Salary)
Department_master(Dept_Code,Dept_Name)
Implement the following
:
A)
1.CreateaViewthatdisplayssomeEmployeedetailssuchasEmployeecode,
Employeename,DepartmentNameandtheirBasicSalary.
2.FindthoseemployeeswhodonotbelongtoDepartmentD102orD105.(Note:Use
setoperator)
B)
CreateaPL/SQLblocktopreparereportinthefollowingformat:
Displaythesalaryslipfortheemployeeinthefollowingformat,whoseEmployee
Codeisprovidedbytheuser.
SalarySlipforthemonthJanuary2011.
EmployeeCode:<E102>EmployeeName:<JohnSmith>
DepartmentName:<Finance>
BasicSalaryDAHRAMedical
P.F.
___________________________________________________________
Deductions:
TotalSalary:_____________
Note:
HRAis15%ofbasicsalary
DAis30%ofbasicsalary
Medicalis1%ofbasicsalary
P.F.is10%ofbasicsalary
8. Competition (Comp_code, Comp_name (Dancing, Painting, GK, etc.) )
Participants(Part_no,Part_name,DOB,Address,EmailID,Contact_number)
Scorecard(Part_no,Comp_code,Judge_no[1,2,3],Marks)
Implement the following
:
A)
1.CreateasequencethatallowsenteringnewCompetitionCodethatmuststart
withCMP,wheneveraninsertionistriedtobedone.
2.Findtheeventnameswhichhavescoredthemaximumscorebytheeachjudgein
total.
B)
1.Createaparameterizedcursortodisplaythetotalscorescoredbyeachstudent
withthecompetitiondetails,thecompetitioneventnamehavetobesuppliedas
theparameter.Ifthegiveneventdoesnotexist,throwanuserdefinedexception
withappropriatemessage.
2.CreateatriggerthatcheckstheCompetitionCodemuststartwithCMP
wheneveraninsertionistriedtobedone.Raiseanuserdefinedexceptionifthe
ruleisviolated
9. Customer(Cust_Id,Cust_Name,Cust_Addr,Cust_City,EmailID,Contact_No)
Magazine(Mag_Id,Mag_Name,Unit_Rate,Type_of_subsciption[weekly,monthly,etc.])
Subscription(Cust_Id,Mag_Id,start_date,end_date)
Implement the following
:
A)
1.FindthosecustomerswhohaventsubscribedPCQuestorChipIndia.(Using
setoperator).
2.Findtoptwomagazineshavingthehighestsaleduringlastonemonth.
B)
1.Createapackageforthefollowing:
CreateafunctiontoreturnNo.ofcustomersincityAhmedabadwhohave
subscribedthemagazinePCQuestafterJuly2010.Ifnosuchcustomerexists,
throwauserdefinedexceptionwithappropriatemessage.
2.Createafunction,whichaccepttheMagazineCodeandreturntheMagazines
nameanditsrate.Ifthemagazinecodedoesnotexist,throwauserdefined
exceptionwithappropriatemessage.
10. Account(ac_no,ac_name,act_type)
Transaction(ac_no,trans_date,tran_type,tran_amount,balance)
Note:Act_typemaybeSforsavingorCforcurrentandtran_typemaybeDfor
depositorWforwithdrawal.
Implement the following
:
A)
1.Findoutthosesavingtransactionsthattookplacebetween10thJanuary2011and
20thJanuary2011andhavewithdrawnanamountgreaterthanRs.50,000.
2.CreateaViewthatdisplaytheaccountinformationhavingabalancegreaterthan
Rs.1,00,000.
B)
1.Createatriggernotallowinginsertion,deletionorupdationonSaturdayandbefore
8:00AM&after6:00PMonAccounttable.
2.Afterevery6monthsallthecustomersaregiven5%interest.Soforcurrentdate,give
interestof6%toallthecustomerswhosebalancearegreaterthanorequalto2000
andinterestof,ontheirbalance.
11. Supplier(sid,sname,contactnum)
Parts(pid,pname,color,unitrate)
Catalog(sid,pid,qty)
TotalPartsAvailable:<TotalCount>
12. Sailor(sid,sname,rating(010),DOB)
Boat(bid,bname,color)
Reserve(sid,bid,date)
Implement the following
:
A)
1.Findthenameofthesailorwhohasnotreservedtheredcoloredboat.
2.Findthenameofthesailorwhoisyoungestamongall.
B)
3.CreateatriggerthatcheckstheBoatCodemuststartwithBwheneveraninsertion
istriedtobedone.Raiseauserdefinedexceptioniftheruleisviolated.
4.CreateaprocedurethatgettheSailorCodefromtheuserandcheckwhetherthat
Sailorwasborninaleapyearornot.Ifthegivensailorcodedoesnotexist,throwa
userdefinedexceptionwithappropriatemessage.
13. Movie(movie_id,movie_name,date_of_release)
Screen(screen_id,location,max_capacity)
Current(movie_id,screen_id,date_of_arrival,date_of_closure)
Note:
Valueofscreen_idmustwithletterS.
ScreenlocationcanbyanyoneofFF,SF,andTF.
Date_of_arrivalmustbelessthanDate_of_closure.
Max_capacityattributeshouldhaveavaluegreaterthan0.
4160
6180
81100Total
15. SubjectMaster(Sub_code,Sub_name)
StudentMaster(Roll_no,Stud_Name,Gender,DOB,Address)
Result(Roll_No,Sub_code,Marks)
SubCode:
SubName:
Total(ineachgroup):
16.
Book_catalog(book_code,title,Publisher_Name,Category_Name,
yr_of_release,total_copies)
Member(member_code,member_name,mem_ship_dt)
Issue(Issue_id,member_code,book_code,issu_ret,issue_date,issue_ret_dt)
Note:
AddaconstrainttoIssuetable,whichwillallowonlyIorRtobeenteredinthe
ISSUE_RETcolumn,whichstorestheactionwhetherthebookisbeingissuedor
returned.
17. Item_master(Item_Cd,Item_Name,Item_Price)
Item_received(Item_Cd,Month,Year,Day,Rec_Qty)
Item_stock(Item_Cd,Month,Year,Open_Stock,Rec_Qty,Close_Stock)
Implement the following
:
A)
1.Createasequencethatcanbeusedtoenternewitemsintoitemtable.
2.ListitemswhoserangeliesbetweenRs.250andRs.500
B)
1.WritetriggersthataffectItem_stocktablefortheinsert,updateanddeleteon
Item_receivedtable.
2.WriteaproceduretoacceptItemNameasinputifitexistsdisplaytheItemPrice
otherwisedisplaythepropermessagethroughtheuseofexception.
Sr#.
1.
2.
3.
ItemName
<code>
<name>
<address>
ItemQty
BillNo :<no>
BillDate :<date>
ItemUnitItemPrice
Amount
TotalAmount:
21. Empmaster(Emp_No,Emp_Name,Basic)
Holidays(Month,Year,No.ofWeeklyOff,No.ofHolidays)
EmpTran(Emp_No,Month,Year,PresenceDays,LoanAmount)
Note:1.
2.
2.
3.
4.
HRAis20%ofbasicsalary
DAis45%ofbasicsalary
Medicalis5%ofbasicsalary
P.F.is4%ofbasicsalary
Salaryisgivenfor(Attendance+Holidays+weeklyoff)days
Holidays:
Absence:
SalaryDays:
Earnings
=======
Basic
Medical
H.R.A.
D.A.
TotalEarning:
:
:
:
Deductions
========
:
P.F.
:
Loan
Prof.Tax
:20Rs.
:
TotalDeduction:
TotalAmounttopay:_____________
22. Student(Stud_Id,Stud_Name,Address,DateofBirth)
Stud-Edu(Stud_Id,DegreeName,YearofPassing,Percentage,Grade)
Implement the following
:
A)
1.Displaythestudentswhoseageismorethan24years.
2.Displaythedataoftop3studentsinMCA,2010.
B)
1.WriteaPL/SQLblocktodisplaythedetailofstudentswhohavedone
MCA.
2.Writeaproceduretoacceptstudidasinputandhandleuserdefinedexception
whennodatafound.
23. Weather(City_Id,Nameofcity,Temperature,Humidity)
Implement the following
:
A)
1.Createasequencethatcanbeusedtoenternewcityintoweathertable.
2.DisplaythedetailofcitywhosenamestartswithM.
B)
1.Writeafunctionwhichacceptsthenameofcity&returnstheTemperature&
Humidify.Alsohandleanexceptionifnameofcitydoesnotexist.
2.Writeatriggerbeforeupdateonweatherforeachrowifnewtemperature>
50thengivethemessageotherwiseupdatethevalue.
Reference Books:
1.Oracle9iPL/SQL,OraclePress
2.IvanBayross,SQL,PL/SQLTheProgrammingLanguageOracle