I've created a unique constraint to my table containing employee account details in an attempt to stop duplicated data inserts.
ALTER TABLE emp ADD CONSTRAINT uq_ UNIQUE (USERNAME, EMP_NAME);
However my problem comes when it comes inserting the test data:
----this first insert should work fine INSERT INTO table_name (id, username, emp_name, regdate) VALUES (1, 'test', 'test1', sysdate);
What I'm trying to prevent is an instance like this were the data about an employee is inserted twice into the table:
INSERT INTO table_name (id, username, emp_name, regdate) VALUES (2, 'test', 'test2', sysdate);
As at the moment the insert runs and adds to the table which I'm trying to prevent it from doing.
Is there a way to combat this, would a trigger be a better option to use?