LISTING 4: Using the getData Function

SQL> create or replace function getData(p_x in sys.anyData) return varchar2
  2  as
  3      l_varchar2 varchar2(4000);

  4      l_rc       number;
  5  begin
  6      case p_x.gettypeName
  7          when 'SYS.NUMBER' then
  8              l_rc := p_x.getNumber(l_varchar2);
  9          when 'SYS.DATE' then

 10              l_rc := p_x.getDate(l_varchar2);
 11          when 'SYS.VARCHAR2' then
 12              l_rc := p_x.getVarchar2(l_varchar2);
 13          else
 14              l_varchar2 := '** unknown **';
 15      end case;
 16  

 17      return l_varchar2;
 18  end;
 19  /

Function created.

SQL> select getData(x) getdata from t;


GETDATA
____________

5
19-MAR-02
hello world