Trigger to check the existing values
899280Apr 2 2012 — edited Apr 3 2012I have a table 'table1' with column' 'ID'.The table1 are loaded with many records.
Now need to create a trigger which will check any new record which is inserting will have the ID already exists in the table1. I wrote the following trigger but giving error 'Sub Query not allowed here'. How can I achieve this. Thank in Advance
CREATE OR REPLACE TRIGGER check_col
BEFORE INSERT
ON table1 for each row
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
if :new.id not in (select disticnt id from table1) then
raise_application_error (-20999,'New id not allowed');
end if;
END ;
/