REVERSING A GIVEN STRING in sql | string logic in sql program :

ALGORITHM:
Get the input string.
Find the length of the string.
Extract the char one by one from the end of the string.
Concatenate the extract character.
Display the concatenated reverse string.
Stop the program.


PROGRAM:
SQL> set serveroutput on
SQL> declare
2 b varchar2(10):='&b';
3 c varchar2(10);
4 l number(2);
5 i number(2);
6 g number(2);
7 d varchar2(10);
8 begin
9 l:=length(b);
10 g:=l;
11 for i in 1..l
12 loop
13 c:=substr(b,g,1);
14 g:=g-1;
15 d:=dc;
16 end loop;
17 dbms_output.put_line('reversed string is');
18 dbms_output.put_line(d);
19 end;
20 /



Post a Comment

0 Comments