This action might not be possible to undo. Are you sure you want to continue?
Patel College of Engineering MCA Department Practical List - 2010
Semester: III Subject: MCA 301(Advanced Database Management Systems) Faculty Name: Patel Mehulkumar D. Batch: 2009-2012
Create following tables and solve the given queries.
1. Salesman SNUM SNAME 1001 PIYUSH 1002 NIRAJ 1003 MITI 1004 RAJESH 1005 ANAND 1006 RAM 1007 LAXMAN CITY LONDON SURAT LONDON BARODA NEW DELHI AHMEDABAD BOMBAY COMMISSION (%) 12 13 11 15 10 10 09
SNUM: A Unique number assign to each salesman.SNAME: The name of salesman. CITY: The location of salesman. COMMISSION: The salesman commission on order.
2. Customer CNUM CNAME 2001 HARDIK 2002 GITA 2003 LAXIT 2004 GOVIND 2005 CHANDU 2006 CHAMPAK 2007 PRATIK
CITY LONDON ROME SURAT BOMBAY LONDON SURAT ROME
RATING 100 200 200 300 100 300 100
SNUM 1001 1003 1002 1002 1001 1007 1004
CNUM: A Unique number assign to each customer. CNAME: The name of customer. CITY: The location of customer. RATING: A level of preference indicator given to this customer. SNUM: A salesman number assign to this customer. 3. Order
Find the highest rating in each city. 3. Find out the largest orders of salesman 1002 and 1007. 12.19 1900. ODATE: The date of order. of salesmen currently having orders. List all orders with zero or NULL amount. 13. 1003 of 10/04/99. List all customers whose names begin with a letter 'C'. List of snum of all salesmen with orders in order table without any duplicates.25 1713.87 ODATE 10/03/99 10/03/99 10/03/99 10/03/99 10/04/99 10/04/99 10/05/99 10/05/99 10/05/99 10/06/99 CNUM 2007 2001 2007 2003 2007 2002 2004 2006 2004 2006 SNUM 1007 1001 1004 1002 1007 1003 1002 1001 1002 1001 ONUM: A Unique number assign to each Order. List all customers excluding those with rating <= 100 or they are located in Rome. 1000. Find the largest order taken by each salesman on 10/03/1997. Count the no.69 767. 18. 15. Calculate the total & average amount ordered. List all customers in descending order of rating. of salesmen registering orders for each day. SNUM: The number of salesman credited with the sale. 5. Count the no. 17. List of rating and name of each customer in Surat. 8. Find the largest order taken by each salesman on each date with salesman commission.00 1309.75 4723. List of all orders for more than Rs. List all order for more than Rs. Show the name of all customers with their salesman's name. 21. Give all the information about all the customers with salesman number 1001. 1000 except the orders of snum. 19. 10. List all customers whose names begins with letter 'A' to 'G' 11. AMOUNT: Amount of order in Rs. 14.ONUM 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 AMOUNT 18. 22.95 9898. CNUM: The number of customer making the order.12 75. Write a query on the order table that will produce the order number. 9. 1. 2. salesman no and amount of commission for that order. List all orders by the customers not located in the same city as their salesman. 20. sname and city of all salesmen.10 5160. List all customers and salesmen who shared a same city.45 1098. List out names and cities of all salesmen in London with commission above 10% 7. Produce the snum. 23. 6. 4. 16. .
Create another table Day totals with two-attribute date and total and insert rows into this table from order table. of customers with the rating above than the average of 'Surat'. Find all pairs of customers served by a single salesman with the salesman's name. Calculate the amount of the salesman commission on each order by customer with rating above 100. 50. Set ratings for all customers in London to NULL. 40. Find all orders with amounts smaller than any amount for a customer in 'Rome'. Calculate the total amount ordered on each day eliminating the days where the total amount as not at least Rs. Find all customers having rating greater than any customer in 'Rome'. 28. . 38. 47. Count the no. Find all customers with orders on 3rd Oct. Salesman Miti has resigned. Create a union of two queries that shows the names. 31. Find all orders of the salesman who services 'Hardik' 33. Set the ratings of all the customers of Piyush to 400. List all orders that are greater than the average of April 10. 2000 above the maximum amount of that day.24. List all customers serviced by salesman with commission above 12%. 49. 53. 58. 39. Double the commission of all salesmen of London. 43. List the commission of all salesmen serving customers in 'London'. 55. cities and ratings of all customers. 59. 35. 26. List all customers whose ratings are equal to or greater than ANY 'Niraj' 51. List all salesmen who are living in the same city without duplicate rows. 30. 37. Increase the rating of all customers in Rome by 100. Produce the name and city of all the customers with the same rating as Hardik'. 42. 57. Find all orders attributed to salesmen in 'London'. Find all the customers who have greater rating than every customer in 'Rome'. Find all customers whose cnum is 1000 above than the snum of Niraj. Extract all orders of Baroda's salesmen. Using correlated sub query find the name and number of all customers with rating equal to maximum for their city. Find all salesmen who have customers with rating > 300 44. 1999 using correlate sub query. Suppose we have a table called sales Manager with the same definition as Salesmen table. 36. 56. Remove all orders of customer Hardik from orders table. Select the name and number of all salesmen who have customers their cities. 29. 46. 27. Those with rating of >=200 should display 'HIGH RATING' and those with < 200 should display 'LOW RATING' 52. Reassign her number to a new salesman Gopal whose city is Bombay and commission is 10%. 41. List all order that has amount greater than at least one of the orders from 5th October 1999. 25. Find all pairs of customers having the same rating with out duplication. Company decides to promote salesmen having total order more than 5000 to Sales Manager. Select all customers whose rating doesn't match with any rating customer of 'Surat'. 45. 1999 34. Fill up the Sales Manager table. 54. Find all salesmen for whom there are customers that follow them alphabetical order. 48. List all customers located in cities where salesman Niraj has customers. 32. Produce the name and rating of all customers who have above average orders.
and the total amount ordered for each day. Create a table Multicust containing the salesmen with more than one customer. List all salesmen in London who had at least one customer located there as well. snum is the primary key and all names contain alphabets only. of customers at each rating. PL/SQL PROGRAM LIST Create following tables. 65. 66. 64.000 TAX NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL FK DEPT_ID NULL DEPT_ID_1 DEPT_ID_2 DEPT_ID_3 DEPT_ID_2 DEPT_ID_4 DEPT_ID_6 DEPT_ID_5 DEPT_ID_3 DEPT_ID_1 DEPT_MASTER PK DEPT_ID DEPT_NAME . Write a command to create the salesmen table so that the default commission is 10% with not NULL permitted. 62. Find the smallest order for each day. Create a view Rate count that gives the count of no. 61. Remove all customers assigned to salesmen in New Delhi.000 40.000 60. the no of orders. Store the information of all salesmen with the customers in their home cities into smcity. 71. the average amount ordered.000 25. Reduce the commission of all salesmen by 2% who produce this order. New Delhi office has closed. List all salesmen in London who didn't have any customer there. 72.60.000 70.000 7.000 50. 67.000 10. Create a view that shows all the number of salesman in each city. Create a table Bonus that contains date wise maximum amount of order for all salesmen. no of salesmen taking orders. Assume that we have a table called smcity.50. 63. PK EMP_NO EMP_NO_1 EMP_NO_2 EMP_NO_3 EMP_NO_4 EMP_NO_5 EMP_NO_6 EMP_NO_7 EMP_NO_8 EMP_NO_9 EMP_NO_10 EMP_NAME RAJESH MUKESH PRAGNESH SANKET DARSHAN BHARAT DILIP HARESH PRAMOD RONAK EMP_MASTER FK EMP_TYPE MNGR_NO CEO CLERK PEON J_CLERK S_CLERK OS S_MANAGER J_MANAGER CLERK PEON NULL EMP_NO_5 EMP_NO_4 EMP_NO_2 EMP_NO_6 EMP_NO_8 EMP_NO_1 EMP_NO_7 EMP_NO_5 EMP_NO_4 SALARY 1.000 80.000 95. 70. Create a view that shows all the customers who have the highest ratings. Delete all salesmen who have at least one customer with a rating of 100 from salesmen table. 69. 68. Create a view to keep track of the total no of customers ordering.
(Use parameterized cursor.000 45.000 In the TRANS_MASTER table TRANS_TYPE is either D=Deposit or W=Withdrawal Do as directed.000 30.000 40.000 5. . Accept employee number from user and calculate balance for that particular employee.000 10. 1 Write a PL/SQL block to calculate department wise total salary and grand total of salary. Your Employee Number is EMP_NO_8.) OUTPUT Total salary of HR department is 57000 Total salary of MARKETING department is 70000 Total salary of SALES department is 65000 Total salary of ACCOUNTS department is 70000 Total salary of FINANCE department is 80000 Total salary of PRODUCTION department is 95000 -----------------------------------------------------------------Grand total of the salary is =============== 587000 PL/SQL procedure successfully completed.) 2 OUTPUT1 Enter value for char_emp_no: 'EMP_NO_8' Welcome HARESH.000 10.000 20.DEPT_ID_1 DEPT_ID_2 DEPT_ID_3 DEPT_ID_4 DEPT_ID_5 DEPT_ID_6 DEPT_ID_7 HR MARKETING SALES ACCOUNTS FINANCE PRODUCTION MAINTANANCE PK TRANS_ID TRANS_ID_1 TRANS_ID_2 TRANS_ID_3 TRANS_ID_4 TRANS_ID_5 TRANS_ID_6 TRANS_ID_7 TRANS_ID_8 TRANS_ID_9 TRANS_ID_10 TRANS_MASTER FK TRANS_DATE EMP_NO TRANS_TYPE 12-FEB-2009 20-FEB-2009 23-MAR-2009 17-MAY-2009 22-DEC-2009 8-FEB-2010 13-MAY-2010 25-JUN-2010 18-JUL-2010 22-AUG-2010 EMP_NO_10 EMP_NO_8 EMP_NO_1 EMP_NO_4 EMP_NO_9 EMP_NO_2 EMP_NO_6 EMP_NO_4 EMP_NO_6 EMP_NO_8 D D D D D D D W W W TRANS_AMT 25.000 15. (Use simple cursor.000 50.
Please enter valid employee number. Write a PL/SQL block that will display all the employees under their managers. PL/SQL procedure successfully completed. EMP_NO_6 (BHARAT) ==================================================================== PL/SQL procedure successfully completed. EMP_NO_8 (HARESH) ==================================================================== EMP_NO_8 (HARESH) is the manager of following employees. EMP_NO_4 (SANKET) ==================================================================== EMP_NO_4 (SANKET) is the manager of following employees. (Use nested cursors parameterized + parameterized) 4 OUTPUT1 Enter value for char_dept_id: 'DEPT_ID_1' . EMP_NO_5 (DARSHAN) ==================================================================== EMP_NO_7 (DILIP) is the manager of following employees. OUTPUT2 Enter value for char_emp_no: 'EMP_NO_89' This employee does not exist. EMP_NO_3 (PRAGNESH) EMP_NO_10 (RONAK) ==================================================================== EMP_NO_5 (DARSHAN) is the manager of following employees. EMP_NO_9 (PRAMOD) EMP_NO_2 (MUKESH) ==================================================================== EMP_NO_6 (BHARAT) is the manager of following employees.Your Current Balance is 20000. PL/SQL procedure successfully completed. Accept department id from user and calculate balance of each employee of that particular department. EMP_NO_7 (DILIP) ==================================================================== EMP_NO_2 (MUKESH) is the manager of following employees.) 3 OUTPUT EMP_NO_1 (RAJESH) is the manager of following employees. (Use nested cursors simple + parameterized.
1. There is no manager above you. OUTPUT3 Enter value for char_emp_no: 'EMP_NO_2' You are MUKESH (EMP_NO_2) Your manager is DARSHAN (EMP_NO_5) 6 PL/SQL procedure successfully completed. PL/SQL procedure successfully completed. Please enter valid one.000 then tax = (salary – 75. If salary < = 75. OUTPUT2 Enter value for char_emp_no: 'EMP_NO_1' You are the CEO. The function should accept employee number as argument. Welcome RONAK.000 + 2.500 .25.Welcome MUKESH. OUTPUT2 Enter value for char_dept_id: 'xyz' This Department does not exist. Create a function that will help in finding manager of particular employee. Write a PL/SQL block that will use above function.000) * 0. PL/SQL procedure successfully completed. Accept employee number from user and display appropriate messages as shown in following outputs.500 Else tax = (salary – 1. 2. PL/SQL procedure successfully completed. Entered employee number is valid or not.30 + 15.25.10 Else If salary < = 1. Function will return appropriate value depending on which you will be able to take appropriate decisions like followings. Enter valid Department ID.000 then tax = (salary -1. Create a procedure to calculate income tax of the employees according to following income tax slab and update the TAX field for all employees in the EMP_MASTER table. Entered employee number is owned by CEO or not etc. OUTPUT1 Enter value for char_emp_no: 'xyz' You have entered invalid employee number.00.000 then tax = 0 Else If salary < = 1. Your Current Balance is 45000.20 + 2.00. Your Current Balance is 25000. 5 PL/SQL procedure successfully completed.000) * 0.000) * 0.
line 9 ORA-04088: error during execution of trigger 'SYSTEM. 1000) * ERROR at line 1: ORA-20001: Transaction date cannot be future date. It should check that the Withdrawal should be only that much amount such that the balance of that particular employee is not zero and is positive.TRIGGER1_EMP_MASTER' OUTPUT2 UPDATE EMP_MASTER SET SALARY=150000 WHERE EMP_NO='EMP_NO_1' * ERROR at line 1: ORA-20001: New salary must be more than the old one.TRIGGER_TRANS_MASTER". It should check that the first transaction of any employee in the TRANS_MASTER table must be Deposit only. 'D'. 1. '9-JAN-2010'. 'D'. -1000) * ERROR at line 1: ORA-20000: Transaction amount cannot be zero or negative. Before inserting it should check that the transaction date is not future date. ORA-06512: at "SYSTEM. NULL. 'PEON'. 'DEPT_ID_1') * ERROR at line 1: ORA-20000: Salary cannot be negative or zero. 'EMP_NO_1'. '9-DEC-2011'.TRIGGER1_EMP_MASTER' Create a trigger that does following and display user friendly messages. Create a trigger that does following and display user friendly messages. PL/SQL procedure successfully completed. ORA-06512: at "SYSTEM.TRIGGER1_EMP_MASTER". Before inserting it should check that the transaction amount is not zero and is positive. Display appropriate message whether updating was successful. line 9 ORA-04088: error during execution of trigger 'SYSTEM. Before updating EMP_MASTER table it should check that new salary is greater than old salary. line 13 . Create a PL/SQL block that will use above procedure. 3. 'EMP_NO_8'.This procedure will have two arguments of number data type. 2.TRIGGER_TRANS_MASTER". 4. Before inserting a record in the EMP_MASTER table it should check that salary is greater than 0. ORA-06512: at "SYSTEM. 1. First argument will be used to capture salary and second argument will return calculated tax in the procedure to the calling PL/SQL block. 'EMP_NO_8'. OUTPUT1 INSERT INTO EMP_MASTER VALUES('EMP_NO_11'. ORA-06512: at "SYSTEM. 'RAHUL'. 2. 8 OUTPUT1 INSERT INTO TRANS_MASTER VALUES('TRANS_ID_11'. line 5 ORA-04088: error during execution of trigger 'SYSTEM. OUTPUT 7 Tax has been updated for all employees successfully.TRIGGER1_EMP_MASTER".TRIGGER_TRANS_MASTER' OUTPUT2 INSERT INTO TRANS_MASTER VALUES('TRANS_ID_11'. -1.
line 17 ORA-04088: error during execution of trigger 'SYSTEM. Create a package and add all the objects created in above practicals. ORA-06512: at "SYSTEM. 'W'.TRIGGER_TRANS_MASTER".TRIGGER_TRANS_MASTER". '9-JAN-2010'. 20001) * ERROR at line 1: ORA-20003: Withdrawal cannot be greater than current balance. 'W'.TRIGGER_TRANS_MASTER' OUTPUT3 INSERT INTO TRANS_MASTER VALUES('TRANS_ID_11'. 1000) * ERROR at line 1: ORA-20002: First transaction for any employee must be deposit (D) only. 'EMP_NO_3'.TRIGGER_TRANS_MASTER' OUTPUT4 INSERT INTO TRANS_MASTER VALUES('TRANS_ID_11'. 'EMP_NO_8'. '9-JAN-2010'. ORA-06512: at "SYSTEM.ORA-04088: error during execution of trigger 'SYSTEM.TRIGGER_TRANS_MASTER' Delete all the objects created above. 9 . line 24 ORA-04088: error during execution of trigger 'SYSTEM.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.