I'm trying to insert data into different tables using a single table and the tables that I'm inserting into have primary keys.
Can anyone guide me how to fix the error?
INSERT
ALL
WHEN TO_CHAR(L_SHIPDATE,'YYYY') = '1995' THEN
INTO YEAR1995
VALUES (L_PARTKEY, L_EXTENDEDPRICE - 0.1*L_EXTENDEDPRICE)
WHEN TO_CHAR(L_SHIPDATE,'YYYY') = '1996' THEN
INTO YEAR1996
VALUES (L_PARTKEY, L_EXTENDEDPRICE - 0.1*L_EXTENDEDPRICE)
WHEN TO_CHAR(L_SHIPDATE,'YYYY') = '1997' THEN
INTO YEAR1997
VALUES (L_PARTKEY, L_EXTENDEDPRICE - 0.1*L_EXTENDEDPRICE)
SELECT distinct L_PARTKEY, L_EXTENDEDPRICE, L_SHIPDATE
FROM LINEITEM;
ERROR at line 1: ORA-00001: unique constraint (TPCHR.YEAR95_PKEY) violated
Here's the table definition
CREATE TABLE YEAR1995
(
Y95_PARTKEY NUMBER(12) NOT NULL,
Y95_PRICE NUMBER(12) NOT NULL,
CONSTRAINT YEAR95_PKEY PRIMARY KEY (Y95_PARTKEY, Y95_PRICE)
);