我看了网上自定义函数,在Oracle SQL*Plus 里写了函数,怎么都没提示成功与否,一点反应都没有,这个是怎么回事,刚接粗ORACL,很多不懂。例如下面的,按回车还是没提示什么。
连接到: 
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining optionsSQL> create or replace function get_user return varchar2 is  
  2     v_user varchar2(50);  
  3   begin  
  4     select username into v_user from user_users;  
  5     return v_user;  
  6   end get_user;
  7  

解决方案 »

  1.   

    再加一個 / 回車create or replace function get_user return varchar2 is  
        v_user varchar2(50);  
         begin  
           select username into v_user from user_users;  
           return v_user;  
         end get_user;
    /
      

  2.   

    SQL> create or replace function get_rundom_day return date is result date;
      2  begin 
      3     SELECT TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2452641,2452641+364)),'J') FROM DUAL; 
      4     return result;
      5  end get_rundom_day;
      6  /
     
    Warning: Function created with compilation errors
      

  3.   


    SELECT TO_DATE(TRUNC(DBMS_RANDOM.VALUE(2452641,2452641+364)),'J') into result FROM DUAL;
      

  4.   

    恩,这个没错,谢谢了。知道用PL/SQL Developer里的生产测试数据如何用自定义的函数。在Tools里的Data Generator有个SQL(sql function),我不知道如何用。