I'm trying to insert a record into a table that's identical to the record that was changed in another table, using a trigger.
I also need to insert whether the operation was an insert, update or delete
CREATE OR REPLACE TRIGGER triggername
AFTER INSERT OR UPDATE OR DELETE
ON tablename
DECLARE
operation_type VARCHAR2;
changed_id VARCHAR2;
BEGIN
IF UPDATING
THEN operation_type := 'Update';
ELSE IF INSERTING
THEN operation_type := 'Insert';
ELSE IF DELETING
THEN operation_type := 'Delete';
END IF;
SELECT id
FROM tablename
WHERE :OLD.record1 != :NEW.record1
OR :OLD.record2 != :NEW.record2
OR :OLD.record3 != :NEW.record3
OR :OLD.record4 != :NEW.record4
OR :OLD.record5 != :NEW.record5
OR :OLD.record6 != :NEW.record6;
INTO changed_id;
INSERT INTO trigger_table.id VALUES(changed_id);
INSERT INTO trigger_table.type VALUES(operation_type);
END;
/
I'm getting an error
"BAD BIND NAME :NEW" or "BAD BIND NAME :OLD" for each of the :NEW or :OLD
shown above