调用软件包时,如何通过三个功能使我的软件包成功显示两个错误



这是整个代码。请帮助我解决错误并成功编译

CREATE OR REPLACE PACKAGE UPDATE_PASS AS
    FUNCTION updatePasswordStudent(
    CurrentP VARCHAR2,
    NewPwd VARCHAR2,
    StudentId NUMBER
    )
  RETURN number
is
    getCount number :=0;  //this line have error

        BEGIN
            Select count(*) into GetCount from users where student_id=StudentId and Password=md5(CurrentP);
            if GetCount = 1
            then 
            update users set Password=md5(NewPwd) where student_id=StudentId and Password=md5(CurrentP);
          insert into users_log(Passwords,student_id,updated_by,action) values(md5(CurrentP),StudentId,StudentId,'Change');
            else
            GetCount := 0;
            end if;
        RETURN GetCount;
        END updatePasswordStudent;
//this line causes an error
    FUNCTION updatePasswordNazim(
    CurrentP VARCHAR2,
    NewPwd VARCHAR2,
    NazimId number)
    RETURN number
        IS
            GetCount number :=0;
          BEGIN
            Select count(*) into GetCount from nazim_login where nazim_id=NazimId and Password=md5(CurrentP);
            if GetCount = 1
            then 
            update nazim_login set Password=md5(NewPwd) where nazim_id=NazimId and Password=md5(CurrentP);
          insert into nazim_password_log(Passwords,nazim_id,updated_by,action) values(md5(CurrentP),NazimId,NazimId,'Change');
            else
            GetCount := 0;
            end if;
        RETURN GetCount;
        END updatePasswordNazim;
    FUNCTION updatePasswordTeacher(
    CurrentP VARCHAR2,
    NewPwd VARCHAR2,
    TeacherId number)
    RETURN number
        IS
            GetCount number :=0;
          BEGIN
            Select count(*) into GetCount from teacher_login where teacher_id=TeacherId and Password=md5(CurrentP);
            if GetCount = 1
            then 
            update teacher_login set Password=md5(NewPwd) where teacher_id=TeacherId and Password=md5(CurrentP);
          insert into teacher_password_log(Passwords,teacher_id,updated_by,action) values(md5(CurrentP),TeacherId,TeacherId,'Change');
            else
            GetCount := 0;
            end if;
        RETURN GetCount;
        END updatePasswordTeacher;
    END UPDATE_PASS;

我尝试了多个过程,但错误仍然相同

CREATE OR REPLACE PACKAGE UPDATE_PASS AS
    FUNCTION updatePasswordStudent(
    CurrentP VARCHAR2,
    NewPwd VARCHAR2,
    StudentId NUMBER
    )
  RETURN number
is
    getCount number :=0;  //this line have error

        BEGIN
            Select count(*) into GetCount from users where student_id=StudentId and Password=md5(CurrentP);
            if GetCount = 1
            then 
            update users set Password=md5(NewPwd) where student_id=StudentId and Password=md5(CurrentP);
          insert into users_log(Passwords,student_id,updated_by,action) values(md5(CurrentP),StudentId,StudentId,'Change');
            else
            GetCount := 0;
            end if;
        RETURN GetCount;
        END updatePasswordStudent;
//this line causes an error
    FUNCTION updatePasswordNazim(
    CurrentP VARCHAR2,
    NewPwd VARCHAR2,
    NazimId number)
    RETURN number
        IS
            GetCount number :=0;
          BEGIN
            Select count(*) into GetCount from nazim_login where nazim_id=NazimId and Password=md5(CurrentP);
            if GetCount = 1
            then 
            update nazim_login set Password=md5(NewPwd) where nazim_id=NazimId and Password=md5(CurrentP);
          insert into nazim_password_log(Passwords,nazim_id,updated_by,action) values(md5(CurrentP),NazimId,NazimId,'Change');
            else
            GetCount := 0;
            end if;
        RETURN GetCount;
        END updatePasswordNazim;

我希望包装成功编译

错误图像

包装包含两个部分:包装规范和一个软件包主体。您正在尝试将两者结合在一起。

尝试这样的事情:

create or replace package update_pass
is
  function updatepasswordstudent
       ( currentp  varchar2
       , newpwd    varchar2
       , studentid number
       )
  return number;
end update_pass;
/
create or replace package body update_pass
as
  function updatepasswordstudent
       ( currentp  varchar2
       , newpwd    varchar2
       , studentid number
       )
  return number
  is
    getcount number := 0;
  begin
    -- logic goes here
    return getcount;
  end updatepasswordstudent;
end update_pass;
/

相关内容

  • 没有找到相关文章

最新更新