PLSQL Prog
PLSQL Prog
r int :=5;
a float;
begin
a:=3.14*r*r;
dbms_output.put_line('Area = '||a);
end;
/
Declare
a int :=10;
b int :=20;
c int :=a;
begin
dbms_output.put_line('Before swap a= '||a);
dbms_output.put_line('before swap b= '||b);
a :=b;
b :=c;
dbms_output.put_line('After swap a= '||a);
dbms_output.put_line('After swap b= '||b);
end;
/
declare
a int :=100;
b int :=2000;
c int :=300;
begin
if a>b and a >c then
dbms_output.put_line('Greatest Number '||a);
elsif b>a and b >c then
dbms_output.put_line('Greatest Number '||b);
else
dbms_output.put_line('Greatest Number '||c);
end if;
end;
/
write PL/SQl block to find the given year is leap year or not.
Declare
year int;
begin
year:=&year;
if mod(year,400)=0 then
dbms_output.put_line('Given Year is Leap Year');
else
dbms_output.put_line('Given Year is not Leap Year');
end if;
end;
/
write PL/SQL block to find
<30000 low
31000>moderate <50000
>50000 high
DECLARE
ENO varchar(10);
SAL INT;
BEGIN
ENO:='&ENO';
SELECT ESAL INTO SAL FROM EMP WHERE EID=ENO;
IF SAL>50000 THEN
DBMS_OUTPUT.PUT_LINE('HIGH SALARY');
ELSIF SAL>30000 AND SAL<50000 THEN
DBMS_OUTPUT.PUT_LINE('MODERATE SALARY');
ELSE
DBMS_OUTPUT.PUT_LINE('LOW SALARY');
END IF;
END;
/