SQL包语法错误

时间:2014-04-06 21:15:10

标签: oracle plsql syntax-error

我遇到了在我为“Project Table”构建的TAPI上找到错误的问题。这是一个语法错误,因为它不会编译,我在下面发布了我的代码和错误...如果有人能够引导我朝着正确的方向前进,我们将不胜感激。

代码

create or replace package body "PROJECT_TAPI" is
--------------------------------------------------------------
-- create procedure for table "PROJECT"
procedure "INS_PROJECT" (
  "P_STARTDATE" in date              default null,
  "P_PROJID"    in number,
  "P_EMPNO"     in number            default null,
  "P_PROJNAME"  in varchar2          default null
) is 

begin

  insert into "PROJECT" (
     "STARTDATE",
     "PROJID",
     "EMPNO",
     "PROJNAME"
  ) values ( 
     "P_STARTDATE",
     "P_PROJID",
     "P_EMPNO",
     "P_PROJNAME"
  );

end "INS_PROJECT";
--------------------------------------------------------------
-- update procedure for table "PROJECT"
procedure "UPD_PROJECT" (
  "P_PROJID" in number,
  "P_STARTDATE" in date              default null,
  "P_EMPNO"     in number            default null,
  "P_PROJNAME"  in varchar2          default null,
  "P_MD5"       in varchar2          default null
) is 

  "L_MD5" varchar2(32767) := null;

begin

  if "P_MD5" is not null then
     for c1 in (
        select * from "PROJECT" 
        where "PROJID" = "P_PROJID" FOR UPDATE
     ) loop

        "L_MD5" := "BUILD_PROJECT_MD5"(
           c1."STARTDATE",
           c1."PROJID",
           c1."EMPNO",
           c1."PROJNAME"
        );

     end loop;

  end if;

  if ("P_MD5" is null) or ("L_MD5" = "P_MD5") then 
     update "PROJECT" set
        "STARTDATE"   = "P_STARTDATE",
        "PROJID"      = "P_PROJID",
        "EMPNO"       = "P_EMPNO",
        "PROJNAME"    = "P_PROJNAME"
     where "PROJID" = "P_PROJID";
  else
     raise_application_error (-20001,'Current version of data in database has changed since user    initiated update process. current checksum = "'||"L_MD5"||'", item checksum = "'||"P_MD5"||'".');  
  end if;

end "UPD_PROJECT";
--------------------------------------------------------------
-- delete procedure for table "PROJECT"
procedure "DEL_PROJECT" (
  "P_PROJID" in number
) is 

begin

  delete from "PROJECT" 
  where "PROJID" = "P_PROJID";

end "DEL_PROJECT";
--------------------------------------------------------------
-- get procedure for table "PROJECT"
procedure "GET_PROJECT" (
  "P_PROJID" in number,
  "P_STARTDATE" out date,
  "P_EMPNO"     out number,
  "P_PROJNAME"  out varchar2
) is 

  ignore varchar2(32676);
begin

  "GET_PROJECT" (
     "P_STARTDATE",
     "P_PROJID",
     "P_EMPNO",
     "P_PROJNAME",
     ignore
  );

end "GET_PROJECT";
--------------------------------------------------------------
-- get procedure for table "PROJECT"
procedure "GET_PROJECT" (
  "P_PROJID" in number,
  "P_STARTDATE" out date,
  "P_EMPNO"     out number,
  "P_PROJNAME"  out varchar2,
  "P_MD5"       out varchar2
) is 

begin

  for c1 in (
     select * from "PROJECT" 
     where "PROJID" = "P_PROJID" 
  ) loop
     "P_STARTDATE" := c1."STARTDATE";
     "P_EMPNO"     := c1."EMPNO";
     "P_PROJNAME"  := c1."PROJNAME";

     "P_MD5" := "BUILD_PROJECT_MD5"(
        c1."STARTDATE",
        c1."PROJID",
        c1."EMPNO",
        c1."PROJNAME"
     );
  end loop;

end "GET_PROJECT";
--------------------------------------------------------------
-- build MD5 function for table "PROJECT"
function "BUILD_PROJECT_MD5" (
  "P_PROJID" in number,
  "P_STARTDATE" in date              default null,
  "P_EMPNO"     in number            default null,
  "P_PROJNAME"  in varchar2          default null,
  "P_COL_SEP"   in varchar2          default '|'
 ) return varchar2 is 

 begin

  return sys.utl_raw.cast_to_raw(sys.dbms_obfuscation_toolkit.md5(input_string=> 
     "P_STARTDATE" ||"P_COL_SEP"||
     "P_EMPNO"     ||"P_COL_SEP"||
     "P_PROJNAME"  ||"P_COL_SEP"||
     ''
  ));

 end "BUILD_PROJECT_MD5";

end "PROJECT_TAPI"; 

错误

Compilation failed,line 46 (21:08:15)
PLS-00306: wrong number or types of arguments in call to 'BUILD_PROJECT_MD5'Compilation    failed,line 46 (21:08:15)
PLS-00306: wrong number or types of arguments in call to 'BUILD_PROJECT_MD5'Compilation failed,line 46 (21:08:15)
PL/SQL: Statement ignoredCompilation failed,line 93 (21:08:15)
PLS-00306: wrong number or types of arguments in call to 'GET_PROJECT'Compilation failed,line 93 (21:08:15)
PL/SQL: Statement ignoredCompilation failed,line 122 (21:08:15)
PLS-00306: wrong number or types of arguments in call to 'BUILD_PROJECT_MD5'Compilation failed,line 122 (21:08:15)
PLS-00306: wrong number or types of arguments in call to 'BUILD_PROJECT_MD5'Compilation failed,line 122 (21:08:15)
PL/SQL: Statement ignored

由于

1 个答案:

答案 0 :(得分:0)

你调用方法有很多错误。

例如这一个:

 "P_MD5" := "BUILD_PROJECT_MD5"(
    c1."STARTDATE",
    c1."PROJID",

字段的顺序错误。它应该是另一种方式。