日期:2014-05-17  浏览次数:20840 次

Oracle包内过程重载的问题
我的ORACLE一个包内有两个重载的过程分别是:
  procedure peoplegrade(use_sname char, use_cno char, use_grade smallint);
  procedure peoplegrade(use_sno number, use_cno char, use_grade smallint);
想实现重载,因为输入的数量都是一样的,第一个输入分别是char和number型,我认为系统能够识别,但是测试代码

declare 
  -- Local variables here
  i number;
begin
  -- Test statements here
  
  student_yk.peoplegrade('0001','009','97');
end;
系统提示有太多的方法符合,就是说系统是没有正确重载,请问我是需要改包内的过程还是修改测试代码,怎么改,谢谢

------解决方案--------------------
Connected to Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 
Connected as scott
 
SQL> 
SQL> create or replace package pak is
2 procedure p(a number);
3 procedure p(a char);
4 end pak;
5 /
 
Package created
 
SQL> 
SQL> create or replace package body pak is
2 procedure p(a number) is
3 begin
4 dbms_output.put_line(a);
5 end;
6 procedure p(a char) is
7 begin
8 dbms_output.put_line('aaaaa' ||a);
9 end;
 10 end pak;
 11 /
 
Package body created
 
SQL> set serveroutput on

SQL> exec pak.p(1);
 
1
 
PL/SQL procedure successfully completed
 
SQL> exec pak.p('1');
 
aaaaa1
 
PL/SQL procedure successfully completed