Oracle SQL - NOT EXISTS - Preventing records from being INSERTed twice
Posted on 2010-01-11
Hello, I have the following query which inserts data into one table with data from another table, as follows:
INSERT INTO TABLE1
WHERE PROD_TYPE in ('MM','MF','IN','LS')
AND TRIM(SHARE_CLASS) <> 'Z'
AND PROD_CUSIP IS NOT NULL
AND PROD_STAT IN ('O','CL')
Pretend there isn't a primary key on table TABLE1. If this SQL was run twice, I want to prevent the same data from being inserted into table TABLE1 twice. I know my solution involves a NOT EXISTS; I just don't know how to write it.