Professional Documents
Culture Documents
#Procedure To Find Square of A Given No
#Procedure To Find Square of A Given No
#Procedure To Find Square of A Given No
declare
a number;
begin
x:=x*x;
end;
begin
a:=23;
square(a);
end;
RETURN number IS
total number(2):= 0;
BEGIN
SELECT count(*)
INTO total
FROM customers;
RETURN total;
END;
/
DECLARE
c number(2);
BEGIN
c :=totalcustomers();
END;
when(NEW.id>0)
DECLARE
sal_diff number;
BEGIN
end;
update customers
set salary=salary+500
where id=2;
delete from customers
where id=2;
declare
sal number(12,2);
ssn1 char(9):='888665555';
begin
from employee77
where ssn=ssn1;
dbms_output.put_line('the employee'||ssn1||''||'has'||sal||'salary');
end;
bdate date,
sex char,
primary key(ssn));
WHEN(new.salary>2500)
DECLARE
Inform_supervisor number;
BEGIN
dbms_output.put_line('salary_voilation');
END;
update emp777
set salary=80000
where ssn='123456789';
## 2.Write a PL/SQL block to display the salary of a particular employee. The social
security number of the employee must be taken as input from the user
DECLARE
sal1 decimal(10,2);
ssn1 char(9);
begin
ssn1:= :x;
from emp8
where ssn=ssn1;
dbms_output.put_line(sal1);
dbms_output.put_line(ssn1);
end;
WHEN(new.salary>25000)
DECLARE
inform number;
BEGIN
dbms_output.put_line('salary violation');
end;
insert into emp8 values('23456178','abcde','01-jan-
1999','f','bangalore',250000,9);
## Write a PL/SQL block to get 3 marks and compute the grade and display the
interpretation of the grade (Average is >=40 and <60 – Pass, >=60 and < 75 –
Good, >=75 and <90 – Very Good, >=90 – Excellent. A-Excellent, B-Very Good, C-
Good, D-Pass, F-Fail).
declare
grade char(1);
begin
grade :=:g;
CASE grade
end case;
end;
declare
a number;
b number;
c number;
begin
if x>y then
z:=x;
else
z:=y;
end if;
end;
begin
a:=23;
b:=26;
max(a,b,c);
dbms_output.put_line('max of (23,26)is:'||c);
end;
a number;
b number;
c number;
RETURN number
IS
z number;
BEGIN
IF x > y THEN
z:= x;
ELSE
Z:= y;
END IF;
RETURN z;
END;
BEGIN
a:= 23;
b:= 45;
c := findMax(a, b);
END;
/
## 7b.create a trigger to update product price history table when the price of the
product is updated in product table.
unit_price number(7,2) );
ON product2
BEGIN
VALUES
(:old.product_id,
:old.product_name,
:old.supplier_name,
:old.unit_price);
END;
UPDATE product2
WHERE product_id = 1