I want to create a package. But sql*plus propmt "warning:created package body has compiled error".I use Chinese version. I tarnslated the Chinese prompt to english. Hope you unterstand.
Please help
thanks
SQL> create or replace package body product
2 as
3 function addType(typeid in varchar2,typename in varchar2,typedescribe in varchar2)
4 return varchar2
5 as
6 maxTypeid varchar2(28);
7 subTypeid varchar2(2);
8 subTypeint int;
9 begin
10 if length(typeid) > 28 then
11 return '-1'; --typeid参数长度必须小于等于28
12 end if;
13 if length(typename) > 50 then
14 retrun '-2'; --typename参数长度必须小于等于50
15 end if;
16 if length(typename) = 0 then
17 return '-3'; --typename参数长度不能等于0
18 end if;
19 if length(typedescribe) > 100 then
20 return '-4'; --typedescribe参数长度不能大于100
21 end if;
22 select max(kind_id) into maxTypeid from prod_kind where kind_id like typeid || '__';
23 if maxTypeid is null then
24 maxTypeid := typeid || '01';
25 else begin
26 subTypeid := substr(maxTypeid,length(maxTypeid)-1);
27 subTypeint := to_number(subTypeid);
28 if subTypeint = 99 then
29 return '-5'; --类别已*达到最大,不能添加类别
30 end if;
31 subTypeid := to_char(subTypeint + 1);
32 maxTypeid := substr(maxTypeid,1,length(maxTypeid)-2) || subTypeid;
33 end;
34 end if;
35 insert into prod_kind (kind_id,kind_name,describe) values (maxTypeid,typename,typedescribe);
36 commit;
37 return maxTypeid;
38 exception
39 with OTHERS then
40 begin
41 return '-6'; --未知错误,添加类别失败
42 end;
43 end;
44 end;
45 /

警告: 创建的包体带有编译错误。