Write a PL/SQL program for Sorting a given number - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Thursday, October 5, 2017

Write a PL/SQL program for Sorting a given number

Sort a Given Set Of Numbers

Program:

DECLARE
PROCEDURE sort_number(numb NUMBER)
IS
a NUMBER;
b NUMBER;
c NUMBER;
numb1 NUMBER := numb;
BEGIN

FOR i IN 1 .. LENGTH(TO_CHAR(numb1))
LOOP

IF c IS NOT NULL THEN
numb1 := REPLACE(numb1,c);
--dbms_output.put_line('AFTER REPLACE numb1: ' || numb1);
END IF;

a := SUBSTR(numb1,1,1);

--dbms_output.put_line('value of a:' || a);
FOR j IN 1 .. LENGTH(TO_CHAR(numb1))
LOOP
b := SUBSTR(numb1,j,1);

IF b < a THEN
a := b;
END IF;
END LOOP;
c := a;
dbms_output.put_line(a);

END LOOP;
END;

BEGIN

sort_number(9834567210);

END;

No comments:

Post a Comment