PL/SQL Program to Reverse a String

Here you will get pl/sql program to reverse a string.

The substr() function returns a part of string. It has following syntax.

substr(string, position, length);

We will use this function to extract character by character from string in reverse order and concatenate it previous extracted character. || is used to concatenate string.

In this way string is reversed.

 

PL/SQL Program to Reverse a String

 

Output

Enter value for str: hello world
old 2: str1 varchar2(50):=’&str’;
new 2: str1 varchar2(50):=’hello world’;
Reverse of String is:dlrow olleh

2 thoughts on “PL/SQL Program to Reverse a String”

Leave a Comment

Your email address will not be published. Required fields are marked *