Showers Epepe
Showers Epepe

Reputation: 1

Oracle PL/SQL bad bind variable

I checked all my fields and everything is fine but i keep on getting this error When i write this trigger on sql command it says trigger has been created but when i checked on the trigger it showed invalid This is my trigger

create or replace trigger "Max_Crew_T1"
   Before insert or update on "CREW"
   for each row 
declare 
   v_count number;
Begin
   select count(*) into v_count from CREW where AirPlaneID=:NEW.AirPlaneID;
   if 
      v_count > 5
   then
      Raise_Application_ERROR(-20343,'Crew number exceeded');
   END IF;
END;

HERE IS THE ERROR MESSAGE;

PLS-00049: bad bind variable 'NEW.AIRPLANEID'

click on the link below for table desc

enter image description here

Upvotes: 0

Views: 578

Answers (1)

pOrinG
pOrinG

Reputation: 935

The error is because you defined the airplane id while creating the table in quotes. I.e "AirPlaneID" hence you need to do the same in the trigger.

It is not a good practice to define case-sensitive columns with quotes as it causes all these issues, its much better to define without quotes eg. create table crew (airplaneid number(6))..etc. Anyway..

Please use below:

create or replace trigger "Max_Crew_T1"
   Before insert or update on "CREW"
   for each row 
declare 
   v_count number;
Begin
   select count(*) into v_count from CREW where "AirPlaneID"=:NEW."AirPlaneID";
   if 
      v_count > 5
   then
      Raise_Application_ERROR(-20343,'Crew number exceeded');
   END IF;
END;

Upvotes: 1

Related Questions