Hi everyone,
When I try to update Reservation table, i've get no data found ERROR
INSERT INTO "RESERVATION" (RESERVATIONID, CUSTOMERID, PAYMENTID, CHECKIN, CHECKOUT, STATUS) VALUES ('8', '100001', '11111', TO_DATE('21/apr/09', 'DD/MON/RR'), TO_DATE('26/apr/09', 'DD/MON/RR'), 'valid')
One error saving changes to table "RESERVATION":
Row 8: ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at "RESERVE_TRIGGER", line 24
ORA-04088: error during execution of trigger 'RESERVE_TRIGGER'
ORA-06512: at line 1
CREATE TABLE:
Reservation
--------------------------------------------------------------------------------
Reservation ID,Customer ID, PaymentID, Checkin(date), Checkout (date), status( check 'valid' or 'cancel')
PK reservationID (NUMBER),
FK CustomerID (NUMBER),
FK PaymentID (NUMBER)
Payment
--------------------------------------------------------------------------------
Payment ID, cardNumber, customerID, amount
PK PaymentID (NUMBER)
FK cardNumber (NUMBER)
ConfirmationEmail
--------------------------------------------------------------------------------
emailID, customerID, reservationID, emailText, emailSubject,dateSent
PK emailID (NUMBER)
FK customerID (NUMBER)
FK reservationID (NUMBER)
Customer
--------------------------------------------------------------------------------
customerID, title, firstName, familyName, specialRequirements, smokingFlag(check 'Y', 'N'), emailAddress
PK customerID (NUMBER)
ALT K emailAddress (VARCHAR2(100))
LoyaltyPoints
--------------------------------------------------------------------------------
AwardID, customerID, awardDate, awardPoints
PK awardID (NUMBER)
FK customerID (NUMBER)
create or replace
TRIGGER
"RESERVE_TRIGGER"
after insert or update
of status on reservation
referencing new as newReservation
for each row
declare
--1st part--
V_confirmation confirmationemail%rowtype;
--2nd part --
V_award loyaltypoints%rowtype;
point_sum number;
point_count number;
too_much_point exception;
no_more_pen exception;
begin
--1st part--
V_confirmation.datesent := to_date(SYSDATE,'dd-mm-yyyy');
V_confirmation.emailsubject := 'Confirmation Checking-Please do not reply this email';
IF inserting THEN
V_confirmation.emailtext := 'This is an confirmation email, you HAVE BOOK This RESERVATION';
ELSIF UPDATING THEN
V_confirmation.emailtext := 'This is an confirmation email, you HAVE change This RESERVATION';
END IF;--FOR CHECKING INSERT OR UPDATE
INSERT INTO confirmationemail
VALUES (mail_seq.nextval, :newReservation.customerID, :newReservation.reservationID, V_confirmation.emailtext,V_confirmation.emailsubject,V_confirmation.datesent);
--2nd part & 3rd part--
select sum(awardpoints)
into point_sum from loyaltypoints where awarddate like '%09' and customerid = :newReservation.customerID
group by loyaltypoints.customerid;
select count(awardpoints)
into point_count from loyaltypoints where awardpoints = -2 and awarddate like '%09' and customerid = :newReservation.customerID
group by loyaltypoints.customerid;
V_award.awarddate := to_date(:newReservation.checkin,'dd-mm-yyyy');
V_award.customerID := :newReservation.customerID;
if(point_sum >= 10) then
raise too_much_point;
end if;
if(point_count >5) then
raise no_more_pen;
end if;
if( :newReservation.checkout - :newReservation.checkin >=5 AND :newReservation.customerID = V_award.customerID and :newReservation.status <> 'cancel' ) then
V_award.awardpoints := 1;
insert into loyaltypoints
values(award_seq.nextval, :newReservation.customerID, V_award.awarddate, V_award.awardpoints);
END IF;
IF(:newReservation.status = 'cancel' ) THEN
V_award.awardpoints := -2;
V_award.awarddate := to_date(SYSDATE,'dd-mm-yyyy');
insert into loyaltypoints
values(award_seq.nextval, :newReservation.customerID, V_award.awarddate, V_award.awardpoints);
END IF; --FOR CANCEL
exception
when too_much_point then
dbms_output.put_line('You will not get any points from this year!!(MAX:10)');
when no_more_pen then
dbms_output.put_line('No more points to deduct for this year....');
end;
I've spend around 4 hours on this error today, this happen when I try to test my trigger is working or not, I think I've delete some data in my Reservation Table, Confirmation Email table, and LoyaltyPoints table, it seems not working after I've delete LoyaltyPoints Table, but I'm not sure this is the case.