Method 1 : By using FOR loop in PLSQL
DECLARE
l_string1 VARCHAR2 (100) := 'deeps sti dna thgil neewteb kcuts si emit ehT';
l_string2 VARCHAR2 (100);
BEGIN
FOR indx IN REVERSE 1 .. LENGTH (l_string1)
LOOP
l_string2 := l_string2 || SUBSTR (l_string1, indx, 1);
--dbms_output.put_line(l_string2);
END LOOP;
DBMS_OUTPUT.put_line (l_string2);
END;
/
Method 2 : By using REVERSE() function available in Oracle
declare
string1 VARCHAR2(100) :='deeps sti dna thgil neewteb kcuts si emit ehT';
begin
SELECT REVERSE(string1) into string1 from dual;
dbms_output.put_line(string1);
end;
/* Since reverse function is available for SQL and is not implemented in PLSQL thats why we can't directly apply it*/
This comment has been removed by a blog administrator.
ReplyDelete