I am a first timer in Oracle and using Netbean IDE 8 and I am trying to prevent deletion of a Hotel from Hotel Table if Room Table has Room details for the Hotel. These 2 tables are on 2 different sites so have to use trigger. I tried the following code but it throws error like following with sql error on line 6, 10, 13, 14,
[Exception, Error code 6,550, SQLState 65000] ORA-06550: line 4, column 19: PLS-00049: bad bind variable '' ORA-06550: line 4, column 30: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
the table structure is
CREATE TABLE Hotel
(
HotelID number not null,
HotelName varchar2(100) not null,
HotelType varchar2(10) not null,
ConstrYear varchar2(10) null,
Country varchar2 (100) not null,
City varchar2 (50) not null,
Address varchar2 (100) not null,
ContactNo varchar2(50) not null,
Email varchar2(100) null,
CONSTRAINT Hotel_pk PRIMARY KEY (HotelID)
);
and for Room
CREATE TABLE Room
(
RoomID number not null,
HotelID raw(16) not null,
RoomNo number not null,
RoomType varchar2(20) not null,
Price numeric(10,2) not null,
RoomDesc varchar2(255) not null,
CONSTRAINT Room_pk PRIMARY KEY (RoomID),
);
What am I doing wrong? Please help.
CREATE OR REPLACE TRIGGER CHECK_Room
BEFORE DELETE on Hotel
FOR each ROW
declare
rowcount number;
begin
SELECT COUNT(HotelID) INTO rowcount
from ROOM@site1
where HotelID = :OLD.HotelID;
if rowcount>0
THEN
Raise_Application_Error (-20100, 'This Hotel has room details in Room table.');
end if;
end;
rowcountvariable, but usingif rowcnt>0. Also useset define offcommand to avoid "bad bind variable" error.