I created a trigger in SQL and it compiles ok but when I run an insert it I get the following error:
SQL Error: ORA-01403: no data found
ORA-06512: at "EOCRIBIN.SHIPMENT_CAPACITY", line 5
ORA-04088: error during execution of trigger 'EOCRIBIN.SHIPMENT_CAPACITY'
01403. 00000 - "no data found"
*Cause: No data was found from the objects.
*Action: There was no data from the objects which may be due to end of fetch.
Here is the trigger :
CREATE OR REPLACE TRIGGER Shipment_capacity
BEFORE INSERT or UPDATE on SHIPMENT_TYPE FOR EACH ROW
DECLARE
NOT_ENOUGH_CAPACITY EXCEPTION;
WEIGHT INTEGER;
BEGIN
SELECT VolumeCapacity
INTO WEIGHT
FROM shipment_type
WHERE ShipmentType = :NEW.ShipmentType;
IF WEIGHT > :new.WeightCapacity THEN
RAISE NOT_ENOUGH_CAPACITY;
END IF;
EXCEPTION
WHEN NOT_ENOUGH_CAPACITY THEN
RAISE_APPLICATION_ERROR(-200003,'Volume capacity exceeds weight limit');
END;
The table consists of the following :
CREATE TABLE SHIPMENT_TYPE
(
ShipmentType varchar(25) primary key,
VolumeCapacity INT,
WeightCapacity INT,
Temperature float
);
Any idea why this error is happening?