Aim - PL/SQL Program to reverse a string.
Sample PLSQL Program: -
declare
str1 varchar2(30);
len number(3);
str2 varchar2(30);
i number(3);
begin
str1:='&str1';
len:=length(str1);
for i in reverse 1..len
loop
str2:=str2 || substr(str1,i,1);
end loop;
dbms_output.put_line('Reverse string is: '||str2);
end;Output of PL SQL Block: -Enter value for str1: hello
old 6: str1:='&str1';
new 6: str1:='hello';
Reverse string is: olleh
4 comments:
no anser
thanks
whats the meaning of line str2:=str2 || substr(str1,i,1);
thanks for sharing!
It helps a lot.
C Programs
Post a Comment
Dont SPAM