PL/SQL Program to Reverse a String
Here you will learn pl/sql program to reverse a string using substr function in pl/sql programming.
PL/SQL Program to Reverse a String
1 2 3 4 5 6 7 8 9 10 11 12 | DECLARE old_str VARCHAR2(50) := 'Hello, PL/SQL'; new_str VARCHAR2(50); BEGIN FOR i IN REVERSE 1..LENGTH(old_str) LOOP new_str := new_str || SUBSTR(old_str, i, 1); END LOOP; DBMS_OUTPUT.PUT_LINE('Old String: ' || old_str); DBMS_OUTPUT.PUT_LINE('New String: ' || new_str); END; / |
Output
Old string: Hello, PL/SQL
New string: LQS/LP ,olleH
Check out our other PL/SQL programs examples