DBMS LAB
DBMS LAB
SESSION - 2023-24
PROJECT FILE
OUTPUT
HELLO WORLD..
OUTPUT
Enter the value for var1: 23
Old 6: var1:&var1;
New 6: var1:=23;
Enter the value of var2: 34
Old 7: var2:&var2;
New 7: var2:=34;
57
begin
i:=2;
flag:=1;
n:=&n;
for i in 2..n/2
loop
if mod(n,i)=0
then
flag:=0;
exit;
end if;
end loop;
if flag=1
then
dbms_output.put_line('prime');
else
dbms_output.put_line('not prime');
end if;
end;
/
OUTPUT
Enter value for n: 12
old 9: n:=&n;
new 9: n:=12;
not prime
begin
n:=&n;
for i in 1..n
loop
fac:=fac*i;
end loop;
dbms_output.put_line('factorial='||fac);
end;
/
OUTPUT
Enter value for n: 10
old 7: n:=&n;
new 7: n:=10;
factorial=3628800
begin
n:=&n;
for i in 1..10
loop
dbms_output.put_line(n||' x '||i||' = '||n*i);
end loop;
end;
/
OUTPUT
Enter value for n: 5
old 6: n:=&n;
new 6: n:=5;
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
A-6 declare
n number;
i number;
rev number:=0;
r number;
begin
n:=&n;
while n>0
loop
r:=mod(n,10);
rev:=(rev*10)+r;
n:=trunc(n/10);
end loop;
dbms_output.put_line('reverse is '||rev);
end;
/
OUTPUT
Enter value for n: 4578
old 8: n:=&n;
new 8: n:=4578;
reverse is 8754
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;
/
OUTPUT
Enter value for n: 6
old 5: n number:=&n;
new 5: n number:=6;
Fibonacci series is:
0
1
1
2
3
5
8
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;
/
OUTPUT
Enter value for n: 7
old 2: n number:=&n;
new 2: n number:=7;
number is odd
begin
len:=length(str1);
for i in reverse 1..len
loop
str2:=str2 || substr(str1,i,1);
end loop;
dbms_output.put_line('Reverse of String is:'||str2);
end;
/
OUTPUT
Enter value for str: hello world
old 2: str1 varchar2(50):=’&str’;
new 2: str1 varchar2(50):=’hello world’;
Reverse of String is:dlrow olleh
if m=rev
then
dbms_output.put_line('number is palindrome');
else
dbms_output.put_line('number is not palindrome');
end if;
end;
/
OUTPUT
Number is palindrome
temp:=a;
a:=b;
b:=temp;
dbms_output.put_line('after swapping:'); dbms_output.put_line('a='||a||'
b='||b);
end;
/
OUTPUT
before swapping:
a=5 b=10
after swapping:
a=10 b=5
if m=s
then
dbms_output.put_line('armstrong number');
else
dbms_output.put_line('not armstrong number');
end if;
end;
/
OUTPUT
Armstrong number
OUTPUT
a=10 b=12 c=5
OUTPUT
**************************