I know the sequence can not be used in these places.
For a SELECT statement:
- In a WHERE clause
- In a GROUP BY or ORDER BY clause
- In a DISTINCT clause
- Along with a UNION or INTERSECT or MINUS
In a sub-query
Please help to achieve the below requirement with conditional insert. Objective is - Need to insert if the name is not exist in the table as its protected by Sequence as primary key.
INSERT
WHEN EXISTS (SELECT 0 FROM TABLE1 WHERE NAME = 'DUPLICATE_NAME_TEST')
THEN
INTO TABLE1 (KEY, NAME, GROUP)
SELECT TESTSEQ.NEXTVAL, 'DUPLICATE_NAME_TEST', 30 FROM DUAL;