Anda di halaman 1dari 4

ACTS Pune

Lab Assignments: 1. Write a program that computes the perimeter and the area of a rectangle. Define your own values for the length and width. (Assuming that L and W are the length and width of the rectangle, Perimeter = 2*(L+W) and Area = L*W. Display the output on the screen using dbms_output.put_line. 2. Write a program that declares an integer variable called num, assigns a value to it, and computes and inserts into the tempp table the value of the variable itself, its square, and its cube. 3. Convert a temperature in Fahrenheit (F) to its equivalent in Celsius (C) and vice versa. The required formulae are:C= (F-32)*5/9 F= 9/5*C + 32 Display the output on the screen using dbms_output.put_line. Data has to be input by the user. 4. Convert a number of inches into yards, feet, and inches. For example, 124 inches equals 3 yards, 1 foot, and 4 inches. Display the output on the screen using dbms_output.put_line. Data has to be input by the user. 5. Write a program that enables a user to input an integer. The program should then state whether the integer is evenly divisible by 5. (Use decode instead of IF statement where required). Display the output on the screen using dbms_output.put_line. Data has to be input by the user. 6. Your block should read in two real numbers and tell whether the product of the two numbers is equal to or greater than 100. Display the output on the screen using dbms_output.put_line. (Use decode instead of IF statement where required). Data has to be input by the user. 7. In a PL*SQL block, create a datatype by the name of addr_type. It should contain the following components: name varchar2 (20) street varchar2 (30) city varchar2 (20) state varchar2 (15)

ACTS Pune
8. Your block should accept the names and addresses of 4 employees in 4 different variables of datatype addr_type. Output the names and addresses of the 4 employees on the screen in the form of Labels as shown below:************************************************************* * Name:Jack ** Name:Scott * * Street:M.G. Road ** Street:Bhosale Marg * * City:- Mumbai ** City:Chennai * * State:Maharashtra ** State:Tamil Nadu * ************************************************************* ************************************************************* * Name:King ** Name:Adams * * Street:Lane No:-2 ** Street:P. M. Road * * City:- Nagpur ** City:Bangalore * * State:Maharashtra ** State:Karnataka * ************************************************************* 9. Input a number and determine whether it is within a given range (for example, between 1 and 10). The low and high values of the range may be input by the user rather than be fixed by the program. Display the output on the screen using dbms_output.put_line. 10. Input three positive integers representing the sides of a triangle, and determine whether they form a valid triangle. Hint: In a triangle, the sum of any two sides must always be greater than the third side. Display the output on the screen using dbms_output.put_line. 11. Check if a given a year is a leap year. The condition is:year should be (divisible by 4 and not divisible by 100) or (divisible by 4 and divisible by 400.) Display the output on the screen using dbms_output.put_line. The year should be input by the user. 12. Write a program that examines all the numbers from 1 to 999, displaying all those for which the sum of the cubes of the digits equal the number itself. Display the output on the screen using dbms_output.put_line. 13. Write a PL*SQL block that reads in a minimum and maximum value for a radius, along with an increment factor, and generates a series of radii by repeatedly adding the increment to the minimum until the maximum is reached. For each value of the radius, compute and display the circumference, area, and volume of the sphere. (Be sure to include both the maximum and the minimum values.). Validate each of the input values to be sure they are positive. If the minimum is typed in place of the maximum, swap the values within the program, and continue execution. Display the results on the screen using dbms_output.put_line. 14. A table consists of the following fields:Invoice Number Varchar2 4 Invoice Date Date Customer Code Number 1 Product Code Number 1 Quantity Sold Number 3 There are ten customers with codes 0 to 9 and five products with codes 0 to 4. The rates of products are Rs. 15, 35, 42, 51 and 60 respectively. Write a program to find the total purchase in Rs. of each customer and total sale of each product using this table and insert these values in two other tables. 15. Write a PL*SQL block to accept a character string from the user. The user should enter a number spelt out. With the help of PL*SQL arrays, write a program for Word to number conversion up to 99 crores. The program should cater to Rs. and paise also. For example, if the user enters:-

ACTS Pune
Rs. Twelve crores, Thirty Four lakhs, Fifty One thousand, Two hundred and Fifty and Seventy five paise only The output of your program should be: - 123451250.75 If the user enters:Rs. Nine thousand, Seven hundred and Twenty Eight only The output of your program should be: - 9728 16. Create the following 3 tables and insert sample data as shown:Ord_mst Ord_no Cust_cd Status 1 C1 P Ord_dtl Ord_no Prod_cd Qty 1 P1 100 1 P2 200 Prod_mst Prod_cd Prod_name Qty_in_stock Booked_qty P1 Floppies 10000 1000 P2 Printers 5000 600 P3 Modems 3000 200 Write a Before Insert trigger on Ord_dtl. Anytime a row is inserted in Ord_dtl, the Booked_qty in Prod_mst should be increased accordingly. Write a Before Delete trigger on Ord_dtl. Anytime a row is deleted from Ord_dtl, the Booked_qty in Prod_mst should be decreased accordingly. 17. Write a stored procedure by the name of Comp_intr to calculate the amount of interest on a bank account that compounds interest yearly. The formula is:I = p (1+ r) y p where:I is the total interest earned. p is the principal. r is the rate of interest as a decimal less than 1, and y is the number of years the money is earning interest. Your stored procedure should accept the values of p, r and y as parameters and insert the Interest and Total amount into tempp table. 18. Create a stored function by the name of Age_calc. Your stored function should accept the date of birth of a person as a parameter. The stored function should calculate the age of the person in years, months and days e.g. 35 years, 3 months, 17 days. The stored function should return the age in years directly (with the help of Return statement). The months and days are to be returned indirectly in the form of OUT parameters. Write a PL*SQL block to accept the date of birth of an employee from the user, call the stored function, and display the age of the employee on the screen. Display the above results on the screen using dbms_output.put_line. 19. Create a package by the name of Payroll_calc. The package should contain separate procedures for DA, HRA, Gross, Tax and Net calculation. Formulae:DA = 10% of Sal for Managers and 5% of Sal for others. HRA = 20% of Sal for employees of department 10 and 7% of Sal for employees of other departments. Gross = Sal + DA + HRA. If Gross exceeds 4000, Tax is to be deducted at 5% of the amount exceeding 4000. If Gross exceeds 5000, Tax is to be deducted at 5% of the amount exceeding 4000 and an additional of 2% of the amount exceeding 5000.

ACTS Pune
Net = Gross Tax. Write a PL*SQL block that calls the procedures from the above package. The PL*SQL block should print the Pay slips for all the employees. The format of the Pay slip should be as follows:****************************************************************** Name:- KING Designation:- PRESIDENT Dept:- ACCOUNTING Sal:- xxx DA:- xxx HRA:- xxx Gross:- xxx Tax:- xxx Net:- xxx ****************************************************************** 20. Write a SELECT statement to display the experience of all the employees (Sysdate Hiredate). Your output should be as follows:5 years 7 months 11 days 9 years 3 months 16 days etc Dont assume that there are 365 days in a year or that there are 30 days in a month. Your solution should even take care of leap years. 21. Create a view of the Salespeople table called Commissions. This view will include only the snum and comm fields. Through this view, someone could enter or change commissions, but only to values between .10 and .20. 22. Some SQL implementations have a built-in constant representing the current date, sometimes called CURDATE or SYSDATE. The word CURDATE can therefore be used in a SQL statement, and be replaced by the current date when the value is accessed by commands such as Select or Insert. We will use a view of the Orders table called Entryorders to insert rows into the Orders table. Create the Orders table, so that CURDATE is automatically inserted for odate if no value is given. Then create the Entryorders view so that no values can be given. 23. Write a command that will enable a user to pull orders grouped by date out of the Orders table quickly. 24. Write a command that puts the following values, in their given order, into the salespeople table: city San Jose, name Blanco, comm NULL, cnum 1100. 25. Write a command that removes all orders from customer Clemens from the Orders table.

Anda mungkin juga menyukai