PL/SQL Program to Reverse a String
declare
str1 varchar2(50):='&str';
str2 varchar2(50);
len number;
i number;
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:
Reverse of String is:v iramukahtnas
PL/SQL procedure successfully completed.
PL/SQL Program to Reverse a String
declare
str1 varchar2(50):='&str';
str2 varchar2(50);
len number;
i number;
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:
Fibonacci series is:
0
1
1
2
3
5
8
13
21
34
55
89
144
PL/SQL Program to Find Factorial of a Number
declare
n number;
fac number:=1;
i number;
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
Sum of Series
Declare
Sum Number := 0;
Begin
For I in 1 .. 5
Loop
Sum := Sum + &Num;
End Loop;
Dbms_Output.Put_Line('Sum = ' || Sum);
End;
Output
Sum = 45
PL/SQL procedure successfully completed.