How to reverse string without using string function?

Questions by vinit0180

Showing Answers 1 - 16 of 16 Answers

Madhava Reddy

  • May 23rd, 2013
 

Code
  1.  



  Was this answer useful?  Yes

PANKAJ

  • Jul 23rd, 2014
 

Code
  1. #include<iostream>

  2. #include<conio.h>

  3. "pankaj"


  Was this answer useful?  Yes

harsh

  • Sep 22nd, 2014
 

Answer:

Code
  1. span style="font-style: italic;">--DBMS_OUTPUT.PUT_LINE(V_reverse);

  Was this answer useful?  Yes

DECLARE
input varchar2(30);
reverse varchar2(30);
n integer(3);
BEGIN
input:=&input;
for n in reverse 1..length(input) loop
reverse:=reverse||substr(input,n,1);
end loop;
dbms_output.put_line(reverse);
end;
/

  Was this answer useful?  Yes

Senthil

  • Jul 9th, 2016
 

Code
  1.  

  Was this answer useful?  Yes

vishalNair

  • Aug 15th, 2016
 

DECLARE
WORD VARCHAR(30):=ANUPAMA;
NEW_WORD VARCHAR(30);
X NUMBER(10) :=0;
BEGIN
X:=LENGTH(WORD);
FOR Y IN 0 ..X-1
LOOP
Z:=SUBSTR(WORD,X-Y,1) ;
NEW_WORD : = NEW_WORD||Z;
DBMS_OUTPUT.PUT_LINE(WORD IS ||NEW_WORD)
END LOOP;
END;

  Was this answer useful?  Yes

pradeep

  • Nov 22nd, 2016
 

set serveroutput on
DECLARE
WORD VARCHAR(30):=ANUPAMA;
NEW_WORD VARCHAR(30);
X NUMBER(10) :=0;
BEGIN
X:=LENGTH(WORD);
FOR Y IN 0 ..X-1
LOOP
NEW_WORD :=SUBSTR(WORD,X-Y,1);
DBMS_OUTPUT.PUT_LINE(WORD IS ||NEW_WORD);
END LOOP;
END;

  Was this answer useful?  Yes

Hemanth

  • Nov 26th, 2016
 

Code
  1.  

  Was this answer useful?  Yes

Gyanaranjan Mishra

  • Jan 9th, 2017
 

In a simpler way
--reverse a string
DECLARE
my_string VARCHAR2(100):=ODISHA;
new_string VARCHAR2(100);
BEGIN
FOR i IN REVERSE 1..Length(my_string)
LOOP
new_string:=new_string||SubStr(my_string,i,1);
-- Dbms_Output.put_line(new_string);
END LOOP;
Dbms_Output.put_line(new_string);
END;
/

  Was this answer useful?  Yes

Dhanyaa

  • Jan 13th, 2017
 

SELECT REVERSE(WELCOME) FROM DUAL;

  Was this answer useful?  Yes

Tarika Bhutani

  • May 25th, 2017
 

Code
  1.  

  Was this answer useful?  Yes

Nani

  • Jan 25th, 2018
 

Select listagg(substr(Nani,rownum,1)) within group(order by rownum des) as rev from tbl connect by level<=length(Nani); you can use column name instead Nani string char.

  Was this answer useful?  Yes

ushodaya

  • May 20th, 2018
 

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;
/

  Was this answer useful?  Yes

Shivam Softa

  • Sep 19th, 2018
 

SELECT LISTAGG(VAL) WITHIN GROUP(ORDER BY LE) FROM
(select LEVEL LE , substr(SHIVAM,-LEVEL,1) VAL FROM DUAL CONNECT BY LEVEL <= LENGTH(SHIVAM));

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions