在创建具有重载功能的包时,请帮助您找到错误。
显示错误:
PL-00103:在遇到以下任何一种情况时遇到符号“NUMOU”:语言。
PL-00103:当遇到以下情况之一时遇到符号“Function”:end not pragma final instantiable order overriding static member constructor map。
代码:
create or replace package over_load as
function print_it(numin varchar2) return number is numou number;
begin
numou := to_number(numin, '999,999.00');
dbms_output.put_line(numou);
return numou;
exception
when others then
dbms_output.put_line('Wrong string format');
return numou;
end;
function print_it(datin date) return varchar2 is datout varchar2(30);
dumcha varchar2(30);
dumdat date;
begin
dumcha := to_char(datin);
dumdat := to_date(dumcha,'FXDD-MON-YYYY');
datout := to_char(datin, 'fmMOn, DD YYYY');
dbms_output.put_line(datout);
return datout;
Exception
when others then
dbms_output.put_line('Wrong input date format');
return '0';
end;
end;
答案 0 :(得分:1)
在Oracle RDBMS
您必须指定包(对于公共方法)和包含所有公共方法实现的包体,并且您可以选择添加一些私有方法。
包装规格:
create or replace package over_load as
function print_it(numin varchar2) return number;
function print_it(datin date) return varchar2;
end;
身体:
create or replace package body over_load as
function print_it(numin varchar2) return number is
numou number;
begin
numou := to_number(numin, '999,999.00');
dbms_output.put_line(numou);
return numou;
exception
when others then
dbms_output.put_line('Wrong string format');
return numou;
end;
function print_it(datin date) return varchar2 is
datout varchar2(30);
dumcha varchar2(30);
dumdat date;
begin
dumcha := to_char(datin);
dumdat := to_date(dumcha,'FXDD-MON-YYYY');
datout := to_char(datin, 'fmMOn, DD YYYY');
dbms_output.put_line(datout);
return datout;
exception
when others then
dbms_output.put_line('Wrong input date format');
return '0';
end;
end;
注意:
要在SQL * Plus中启用DBMS_OUTPUT的输出,必须启用serveroutput
:
SQL> set serveroutput on size 30000;