hi lly:  我在数据库上作了一个测试,和你的情况一样,好像只有存储过程才可以用exec  ,你把你的fun_b做成存储过程procedure 再试一试

解决方案 »

  1.   

    函数和过程不同的是:函数的返回值必须有返回的对象,比如下面的写法都是合法的:
    delcare
      a number(10);
    begin
      a := pack_lly_test.fun_b(1.0);
    end;
    ---------------------------------
    begin
      debug.print to_char(pack_lly_test.fun_b(1.0));
    end;
    ---------------------------------
    begin
      if pack_lly_test.fun_b(1.0) > 1 then
         ...
      end if;
    end;
      

  2.   

    函数的返回值要有办法处理才行
    exec dbms_output.put_line(pack_lly_test.fun_b(1.0));
      

  3.   

    多谢各位,我明白是什么原因了。不过,我还想问一问,在sql/plus 中:
    SQL > exec dbms_output.put_line(pack_lly_test.fun_b(1.0));
    PL/SQL 过程已成功完成,但没有显示结果。 我想把结果显示出来,用什么办法呢?
    SQL>  declare a number :=0;
      2   a := pack_lly_test.fun_b(1.0);
      3  .......
    下一步怎么做呢?
      

  4.   

    在执行函数前,执行一个SQL/PLUS环境变量设置的命令:
    SET SERVEROUTPUT ON