Friday, May 26, 2017

Reverse A given number using PL/SQL Procedure



Using PL/SQL its very simple and easy to reverse a given number.



CREATE OR REPLACE PROCEDURE REVERSE_NUM(NUM NUMBER)IS
RNO NUMBER;
BEGIN
DBMS_OUTPUT.PUT_LINE('GIVEN NUMBER IS :' || NUM);
FOR I IN REVERSE 1..LENGTH(NUM)
LOOP
RNO := RNO || SUBSTR(NUM,I,1);
END LOOP;
DBMS_OUTPUT.PUT_LINE('REVERSE NUMBER IS : ' || RNO);
END;
/

To Execute this procedure use the below command:

EXECUTE REVERSE_NUM(1234);