Assignment 05 Jyoti
Assignment 05 Jyoti
Name-Jyoti Bist
3rd year,CSE
PL/SQL
1.Write a PL/SQL program to arrange the number of two variables in such a way that the small
number will store in num_small variable and large number will store in num_large variable.
DECLARE
num_small NUMBER;
num_large NUMBER;
BEGIN
num_small := num1;
num_large := num2;
ELSE
num_small := num2;
num_large := num1;
END IF;
END;
2.Write a PL/SQL procedure to calculate the incentive on a target achieved and display the
message either the record updated or not.
incentive NUMBER;
rows_updated NUMBER;
BEGIN
IF target_achieved >= 50000 THEN
ELSE
END IF;
rows_updated := SQL%ROWCOUNT;
ELSE
END IF;
END;
DECLARE
num NUMBER := 7;
BEGIN
IF MOD(num, 2) = 0 THEN
ELSE
END IF;
END;
4.Write a PL/SQL procedure to calculate the incentive on a specific target otherwise a general
incentive to be paid using IF-THEN-ELSE.
BEGIN
ELSE
incentive := 5000;
END IF;
END;
5.Write a PL/SQL program to check whether a date falls on weekend i.e. SATURDAY or SUNDAY.
DECLARE
day_name VARCHAR2(20);
BEGIN
ELSE
END IF;
END;
6.Write a PL/SQL procedure to calculate incentive achieved according to the specific sale limit.
incentive NUMBER;
BEGIN
ELSE
END IF;
END;
7.Write a PL/SQL program to count the number of employees in department 50 and check whether
this department has any vacancies.
DECLARE
emp_count NUMBER;
BEGIN
ELSE
END IF;
END;
DECLARE
description VARCHAR2(50);
BEGIN
CASE grade
END CASE;
END;
9.Write a PL/SQL program to count the number of employees in a specific department and check
vacancies.
DECLARE
emp_count NUMBER;
BEGIN
ELSE
END IF;
END;
10.Write a PL/SQL program to display the description against a grade using CASE statement.
DECLARE
BEGIN
END;
11. PL/SQL Program to Display Grade Description using CASE Statement with EXCEPTION
DECLARE
grade_description VARCHAR2(100);
BEGIN
grade_description :=
CASE grade
END;
EXCEPTION
END;
12. PL/SQL Program to Check Whether a Given Number is Positive, Negative, or Zero
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('Positive');
DBMS_OUTPUT.PUT_LINE('Negative');
ELSE
DBMS_OUTPUT.PUT_LINE('Zero');
END IF;
EXCEPTION
END;
DECLARE
BEGIN
DBMS_OUTPUT.PUT_LINE('Digit');
ELSIF ((ch >= 'A' AND ch <= 'Z') OR (ch >= 'a' AND ch <= 'z')) THEN
DBMS_OUTPUT.PUT_LINE('Letter');
ELSE
EXCEPTION
END;
14. PL/SQL Program to Convert Temperature from Fahrenheit to Celsius and Vice Versa
DECLARE
celsius NUMBER;
BEGIN
EXCEPTION
END;
DECLARE
day_name VARCHAR2(20);
BEGIN
EXCEPTION
END;