Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
13 views

PL SQL Programme

Uploaded by

Mansi Vagadiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

PL SQL Programme

Uploaded by

Mansi Vagadiya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1.

PL/SQL Program to Check Number is Odd or Even

declare
n number:=&n;
begin
if mod(n,2)=0
then
dbms_output.put_line('number is even');
else
dbms_output.put_line('number is odd');
end if;
end;
/

2.Write a PL/SQL block for insertion into table EMPDET table with the following.

Calculations:

HRA= 50% of BASIC DA= 20% of BASIC PF= 7% of BASIC

NETPAY= BASIC + HRA + DA + PF

EMPDET (ENO, ENAME, DEPTNO, BASIC, HRA, DA, PF )

Create table empdet(eno number, ename varchar2(20),


deptno number, basic number,
HRA number(10,2), DA number(10,2), PF number(10,2),
NETPAY number(10,2));

DECLARE
eno number;
ename varchar2(20);
deptno number;
basic number;
HRA number(10,2);
DA number(10,2);
PF number(10,2);
NETPAY number(10,2);
BEGIN
eno := &eno;
ename:=&ename;
deptno:=&deptno;
basic := &basic;
HRA := 0.5 * basic;
DA := 0.2 * basic;
PF := 0.07 * basic;
netpay := basic + hra + da + pf;
insert into empdet values (eno,ename,deptno,basic,hra,da,pf,netpay);
END;/

3.Write a PL/SQL block that will accept student id number from the user, and
check is student attendance is less than 80% then display message that student
cannot appear in exam.

create table student


(stud_id number(5)primary key,
stud_name varchar2(10),
stud_att number(5));

insert into student values(1,'hitesh',120);


insert into student values(2,'kamlesh',160);
insert into student values(3,'keyur',190);
insert into student values(4,'mahesh',110);
insert into student values(5,'suresh',115);

DECLARE
xstud_id number(5);
xstud_att number(5);
xtotal_days number(3):=200;
BEGIN
xstud_id:=&xstud_id;
select stud_att into xstud_att from student where stud_id=xstud_id;
IF(xstud_att<(xtotal_days*0.80))
THEN
dbms_output.put_line('This student can not attend exam');
ELSE
dbms_output.put_line('This student can attend exam');
END IF;
END;
/
PL/SQL Program for Fibonacci Series
declare
first number:=0;
second number:=1;
third number;
n number:=&n;
i number;
begin
dbms_output.put_line('Fibonacci series is:'); dbms_output.put_line(first);
dbms_output.put_line(second);
for i in 2..n
loop
third:=first+second;
first:=second;
second:=third;
dbms_output.put_line(third);
end loop;
end;
/

You might also like