-1

I have a interview question to write a function which takes input as varchar and the output should give in reverse order of input.

This is the code I wrote

`

SQL> create or replace function fn( id in varchar2) return varchar2 is 
2  input varchar2(25) := id;
3
4  begin
5
6  dbms_output.put_line(reverse(input));
7
8  return input;
9
10  end;
11  /

Warning: Function created with compilation errors.

LINE/COL ERROR
-------- ------------------------------------------------------------
6/1      PL/SQL: Statement ignored
6/22     PLS-00201: identifier 'REVERSE' must be declared
SQL> select reverse(ename) from emp;
`

Help me with this

Reverse keyword working in SQL where in PLSQL doesn't. why?

krokodilko
  • 35,300
  • 7
  • 55
  • 79
siva krishna
  • 122
  • 8

1 Answers1

-1

enter image description here

I got the answer now, but I want to know is this perfect answer or is there any other I can do this?

siva krishna
  • 122
  • 8
  • 2
    If you want reviews of working code, you want [codereview.se]. Make sure you understand their guidelines. But... It sounds like you haven't submitted this for the interview yet. Having other people review it would not be a reflection of *your* skills, now would it? – jpmc26 Apr 02 '16 at 06:26
  • 3
    Why to use cursor and open fetch??? It can be simply a SELECT INTO statement and RETURN the output in the function. – Avrajit Roy Apr 02 '16 at 07:02