Google Search

Wednesday, October 12, 2011

Write a PL/SQL Program to display the number in Reverse Order


Write a PL/SQL Program to display the number in Reverse Order

declare
a number;
rev number;
d number;
begin
a:=&a;
rev:=0;
while a>0
loop
d:=mod(a,10);
rev:=(rev*10)+d;
a:=trunc(a/10);
end loop;
dbms_output.put_line('no is'|| rev);
end;
/

OUTPUT:

SQL> @ REVERSE2.sql
Enter value for a: 536
old   6: a:=&a;
new   6: a:=536;
no is 635

PL/SQL procedure successfully completed.

0 comments:

Post a Comment