What is the compiled error
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: What is the compiled error

Hybrid View

  1. #1
    Join Date
    Sep 2001
    Posts
    99
    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 /

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

  2. #2
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    Add after text of package

    create or replace ...
    ...

    end;
    /

    SHOW ERRORS;

    and you can see with errors was in this packsge.



  3. #3
    Join Date
    Sep 2001
    Posts
    99

    how correct this error?

    thank you. I corrected all errors except that. That error is about Exception. Could you help me? sorry, I can't translate these Chinese to English.

    SQL> show errors
    PACKAGE BODY PRODUCT 出现错误:

    LINE/COL ERROR
    -------- ---------------------------------------------------
    39/6 PLS-00103: 出现符号 "WITH"在需要下列之一时:
    pragmawhen
    符号 "when在 "WITH" 继续之前已插入。
    ocean

  4. #4
    Join Date
    Sep 2001
    Posts
    99

    ok,now I know

    the word "with" should be "when"
    thanks
    ocean

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width