I am trying to insert data into a table where an id from a table isn't distinct however, I get the following error message:
PL/SQL: ORA-02287: sequence number not allowed here.
What is the best way to get around this?
I have copied the code below;
INSERT INTO data_quality
SELECT QLTY_SEQ.nextval, userid, 'Duplicate ID'
FROM user
HAVING COUNT(DISTINCT(userid)) = 1;
Thank You in Advance.
You have more than one issue here: once you fixed the sequence, you will have an error due to the fact that you are applying an HAVING
without a GROUP BY
. You probably need :
INSERT INTO data_quality
SELECT QLTY_SEQ.nextval, userid, 'Duplicate ID'
FROM
(
SELECT userid
FROM user
GROUP BY userid
HAVING COUNT(DISTINCT(userid)) = 1
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.