【问题标题】:Subprogram od cursor 'ADD_student'is declared in a package specification and must be defined in the package body子程序 od cursor 'ADD_student' 在包规范中声明,必须在包主体中定义
【发布时间】:2016-09-18 19:37:59
【问题描述】:

子程序和游标“ADD_student”在包规范中声明,并且必须在包主体中定义。我查了一下,不知道怎么回事。

包声明:

create or replace PACKAGE students_package AS 
PROCEDURE add_student(s_name STUDENTS.STUDENT_NAME%type, 
s_surname STUDENTS.SURNAME%type, 
s_pesel STUDENTS.pesel%type, 
s_date STUDENTS.DATE_OF_BIRTH%type, 
s_place STUDENTS.PLACE_OF_BIRTH%type, 
s_behaviour STUDENTS.BEHAVIOR%type, 
s_disease STUDENTS.TYPE_OF_DISEASE%type); 
procedure delete_student(s_id students.student_id%type); 
procedure edit_student(s_id STUDENTS.STUDENT_ID%type, 
s_name STUDENTS.STUDENT_NAME%type, 
s_surname STUDENTS.SURNAME%type, 
s_pesel STUDENTS.pesel%type, 
s_date STUDENTS.DATE_OF_BIRTH%type, 
s_place STUDENTS.PLACE_OF_BIRTH%type, 
s_behavior STUDENTS.BEHAVIOR%type, 
s_disease STUDENTS.TYPE_OF_DISEASE%type); 
END students_PACKAGE;

主体:

create or replace PACKAGE BODY students_package AS 
PROCEDURE add_student(s_name  STUDENTS.STUDENT_NAME%type, 
s_surname  STUDENTS.SURNAME%type, 
s_pesel  STUDENTS.pesel%type, 
s_date  STUDENTS.DATE_OF_BIRTH%type, 
s_place  STUDENTS.PLACE_OF_BIRTH%type, 
s_behavior  STUDENTS.BEHAVIOR%type, 
s_disease  STUDENTS.TYPE_OF_DISEASE%type)  IS 
BEGIN INSERT INTO     students(STUDENT_NAME,SURNAME,PESEL,DATE_OF_BIRTH,PLACE_OF_BIRTH,BEHAVIOR,TYPE_OF_DISEASE) 
VALUES (s_name ,s_surname ,s_pesel ,s_date ,s_place ,s_behavior ,s_disease); 
end add_student; 
procedure edit_student(s_id STUDENTS.STUDENT_ID%type,
s_name STUDENTS.STUDENT_NAME%type, 
s_surname STUDENTS.SURNAME%type, 
s_pesel STUDENTS.PESEL%type, 
s_date STUDENTS.DATE_OF_BIRTH%type, 
s_place STUDENTS.PLACE_OF_BIRTH%type, 
s_behavior STUDENTS.BEHAVIOR%type, 
s_disease STUDENTS.TYPE_OF_DISEASE%type)is 
BEGIN update students 
set students.STUDENT_NAME=s_name,students.SURNAME=s_surname,students.PESEL=s_pesel, 
students.DATE_OF_BIRTH=s_date,students.PLACE_OF_BIRTH=s_place, 
students.BEHAVIOR=s_behavior,students.TYPE_OF_DISEASE=s_disease 
where students.STUDENT_ID = s_id; 
end edit_student; 
procedure delete_student(s_id STUDENTS.STUDENT_ID%type) is 
begin update students 
set students.STUDENT_ID=null,students.SURNAME=null,students.PESEL=null, students.DATE_OF_BIRTH=null,
students.PLACE_OF_BIRTH=null, students.BEHAVIOR=null,students.TYPE_OF_DISEASE=null 
where students.STUDENT_ID = s_id; 
end delete_student; 
END students_package;

我不知道怎么了。

我还有一个触发器:

create or replace TRIGGER "STUDENTS_TRIGGER" 
    before insert on 
    STUDENTS 
    for each row begin :new.student_id := students_auto_incr.nextval; 
    end;

和顺序:

CREATE SEQUENCE  "KONRAD"."STUDENTS_AUTO_INCR"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;

【问题讨论】:

    标签: sql plsql oracle11g


    【解决方案1】:

    参数s_behaviour在规范和包中的拼写不同:

    s_behaviour STUDENTS.BEHAVIOR%type, 
    

    对比

    s_behavior STUDENTS.BEHAVIOR%type, 
    

    【讨论】:

    • 修改后还是一样:/
    • LOOOOL 它是一个退格键! ****之母
    猜你喜欢
    • 2014-12-18
    • 1970-01-01
    • 2022-01-04
    • 2020-04-17
    • 1970-01-01
    • 1970-01-01
    • 2014-11-07
    • 2018-10-13
    • 1970-01-01
    相关资源
    最近更新 更多