Infolinks

Thursday, 21 June 2012

PL/SQL Procedure to reverse a string

Use the following PL/SQL Procedure to reverse a string

create or replace procedure rev(x in varchar2) as
c char(1);
i number;
begin

for i in 1..length(x) loop
select substr(x,length(x)-i+1,1) into c from dual;
dbms_output.put(c);
end loop;
dbms_output.put_line(' ');
end;
/

SQL> set serverout on
SQL> exec rev('Java')

Output: avaJ

No comments:

Post a Comment