-3
我試圖在oracle apex中創建一個觸發器,它將選擇我在UniversityRefNo列中的所有數據,並且不允許用戶放入已存在的值。但是,我不斷收到此錯誤:"ORA-24344: success with compilation error."
如果有人可以告訴我什麼即時做錯了,那將是很大的。ORA-24344:編譯錯誤成功。 Trigger apex
CREATE TABLE VOLUNTEER(
Volunteer_id NUMBER(5) PRIMARY KEY,
Title VARCHAR2(5),
VolName VARCHAR2(30),
UniversityRefNo VARCHAR2(10),
Address_Line_1 VARCHAR2(30),
Address_Line_2 VARCHAR2(12),
PostCode VARCHAR2(12),
Mobile_Number NUMBER(12),
Home_Number NUMBER(12),
Email VARCHAR2(25),
Ethnic_Group VARCHAR2(10),
VolunteerType VARCHAR2(10),
Register_Disable VARCHAR2(3),
Gender VARCHAR2(1),
Medical_Details VARCHAR2(20),
PassPortNumber NUMBER(10),
Nationality VARCHAR2(10),
Passport_Expiry_Date DATE,
Date_of_Birth DATE,
Course_Name VARCHAR2(20),
Course_Year VARCHAR2(10),
Area_of_work VARCHAR2(15),
StaffManagerName VARCHAR2(20),
StaffManagerEmail VARCHAR2(20),
StaffManagerPhone VARCHAR2(12));
CREATE or replace trigger unirefnoTrigger
before insert or update of UniversityRefNo ON VOLUNTEER for each row
begin
SELECT UniversityRefNo from VOLUNTEER
if(UniversityRefno = :new.UniversityRefNo) then raise application error(UniversityRefNO || :new.UniversityRefNo || 'already exists');
end if;
end;
我覺得OP的目的是給終端用戶比一個更具描述性的錯誤消息「ORA-00001:唯一約束(constraint_name命令)違反了」,但是請注意,有更好的方法來做到這一點。 – Typo