对student进行增删改
drop package TechEd_pkg_Student;
CREATE OR REPLACE PACKAGE TechEd_pkg_Student AS
FUNCTION F_CREATE(p_id TechEd_T_Students.Id%TYPE,
p_adress TechEd_T_Students.Adress%TYPE,
p_name TechEd_T_Students.Name%TYPE
)
RETURN TechEd_T_Students.ID%TYPE;
PROCEDURE SP_UPDATE(p_id TechEd_T_Students.Id%TYPE,
p_adress TechEd_T_Students.Adress%TYPE,
p_name TechEd_T_Students.Name%TYPE
));
PROCEDURE SP_DELETE(p_id TechEd_T_Students.ID%TYPE);
END TechEd_pkg_Student;
CREATE OR REPLACE PACKAGE BODY TechEd_pkg_Student AS
FUNCTION F_CREATE(p_id TechEd_T_Students.Id%TYPE,
p_adress TechEd_T_Students.Adress%TYPE,
p_name TechEd_T_Students.Name%TYPE)
RETURN TechEd_T_Students.ID%TYPE AS
V_ID TechEd_T_Students.ID%TYPE;
BEGIN
--获得值
SELECT Sequence_TechEd_T_Students_Id.NEXTVAL INTO V_ID FROM DUAL;
--新增
INSERT INTO TechEd_T_Students
(ID, NAME, Adress)
VALUES
(V_ID, p_name, p_adress);
--返回
RETURN V_ID;
--异常
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END F_CREATE;
PROCEDURE SP_UPDATE(p_id TechEd_T_Students.Id%TYPE,
p_adress TechEd_T_Students.Adress%TYPE,
p_name TechEd_T_Students.Name%TYPE) AS
BEGIN
--修改
UPDATE TechEd_T_Students
SET NAME = p_name, Adress = p_adress
WHERE ID = p_id;
--异常
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END SP_UPDATE;
PROCEDURE SP_DELETE(p_id TechEd_T_Students.ID%TYPE) AS
BEGIN
DELETE TechEd_T_Students WHERE ID = p_id;
END SP_DELETE;
END TechEd_pkg_Student;