參考程式碼:
包stuPack新增程式碼如下:
PROCEDURE usp_InsertStudent (
vage NUMBER,vstuName VARCHAR2);
包stuPack的程式包主體新增程式碼如下
vage NUMBER,vstuName VARCHAR2) As
BEGIN
INSERTINTOSTUDENT(stuName,age)
VALUES(vstuName,vage);
END;
主鍵自增方案:
create sequencestuSeq;
CREATEORREPLACETRIGGER stu_TRG
BEFOREINSERTORUPDATEOF stuID
ON Student
FOREACHROW
IF INSERTING THEN
SELECT stuSeq.NEXTVAL INTO :NEW.stuID FROM DUAL;
ELSE
RAISE_APPLICATION_ERROR(-20020, "不允許更新stuID值!");
ENDIF;
參考程式碼:
包stuPack新增程式碼如下:
PROCEDURE usp_InsertStudent (
vage NUMBER,vstuName VARCHAR2);
包stuPack的程式包主體新增程式碼如下
PROCEDURE usp_InsertStudent (
vage NUMBER,vstuName VARCHAR2) As
BEGIN
INSERTINTOSTUDENT(stuName,age)
VALUES(vstuName,vage);
END;
主鍵自增方案:
create sequencestuSeq;
CREATEORREPLACETRIGGER stu_TRG
BEFOREINSERTORUPDATEOF stuID
ON Student
FOREACHROW
BEGIN
IF INSERTING THEN
SELECT stuSeq.NEXTVAL INTO :NEW.stuID FROM DUAL;
ELSE
RAISE_APPLICATION_ERROR(-20020, "不允許更新stuID值!");
ENDIF;