
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to Reverse a String in PL/SQL using C++
Pl/SQL is a block-structured language that combines SQL's functionality with procedural commands. In this article, we will discuss a program in PL/SQL to reverse a given string for example −
Input : taerGsIdoG Output : GodIsGreat Explanation : reverse string of “taerGsIdoG” is “GodIsGreat”. Input : LQS Output : SQL Explanation Reverse string of “LQS” is “SQL”.
Approach to find The Solution
- First, you need to find the length of the given string.
- Now you can traverse the line but in a reversed order.
- Store each character in another string while traversing.
- At last, you can print the reversed string.
Example
DECLARE -- declaring variables to be used. input_string VARCHAR(50) := 'taerGsIdoG'; length NUMBER; reversed_string VARCHAR(20); BEGIN -- finding the length of the string. length := Length(input_string); -- traversing the string in reversed order. FOR i IN REVERSE 1.. length LOOP -- storing each character in reversed_string variable reversed_string := reversed_string || Substr(input_string, i, 1); END LOOP; dbms_output.Put_line(‘Reversed string : ' || reversed_string); END;
Output
Reversed string: GodIsGreat
Conclusion
In this article, we discuss a PL/SQL programming language that is very simple; it feels like using ordinary English to give the command to the system, which is a block-structured language. We also discussed a program to reverse a string in PL/SQL language. We hope you find this article helpful.
- Related Questions & Answers
- Reverse a Number in PL/SQL
- Find the factorial of a number in pl/sql using C++.
- How to reverse a String using C#?
- Difference between SQL and PL/SQL
- What is PL/SQL?
- How to capture Oracle errors in PL/SQL?
- Difference Between T-SQL and PL-SQL
- Count no. of characters and words in a string in PL/SQL
- Block of PL/SQL in Oracle DBMS
- Print pyramid of tutorialspoint in PL/SQL
- Program for Fibonacci numbers in PL/SQL
- Explain the PL/SQL Engine in DBMS
- Floyd's triangle in PL/SQL
- Reverse a string using the pointer in C++
- How to quickly reverse a string in C++?
Advertisements