私のデータベースはホテル予約システムのデータベースです。現在の日付が部屋のcheck_inとcheck_outの値の間にあるかどうかに基づいて、新しい予約が行われる前に、私のトリガは部屋の空き状況を変更します。トリガー・エラー:ORA-01403挿入時にデータが見つかりません
挿入ステートメントでトリガーを発射しようとすると、データが見つかりませんでした。私はこの問題の助けに感謝します。
エラー:
SQL Error: ORA-01403: no data found ORA-06512: at "USER.ROOM_STATUS", line 5 ORA-04088 error during execution of trigger 'USER.ROOM_STATUS' - no data found *Cause: No data was found from the objects
トリガー:
create or replace trigger room_status
before insert on reservation
for each row
declare
status_in room.status%type;
error1 exception;
begin
select status into status_in
from room
where room.room_id = :old.room_id;
if sysdate between :old.check_in and :old.check_out then
update room
set status = 'F'
where room_id = :old.room_id;
else
update room
set status = 'T'
where room_id = :old.room_id;
end if;
exception
when error1 then
raise_application_error(-20100,'Insert Cancelled');
end;
INSERT文:
insert into reservation
values(reservation_sequence.nextval,to_date('05-03-2017','mm/dd/yyyy'),
to_date('05-07-2017','mm/dd/yyyy'), 116, 170);
テーブル:
create table roomType
(room_type varchar2(20) constraint roomType_pk primary key,
room_rate number(4));
create table room
(room_id number(3) constraint room_pk primary key,
room_type varchar2(15) constraint room_fk references roomType,
status char(1));
create table guest
(guest_id varchar2(5) constraint guest_pk primary key,
first_name varchar2(20),
last_name varchar2(20),
email varchar2(30),
phone varchar2(10));
create table reservation
(reservation_id number(6) constraint reservation_pk primary key,
check_in date,
check_out date,
room_id number(3),
guest_id varchar2(5),
foreign key (room_id) references room(room_id),
foreign key (guest_id) references guest(guest_id));