Cursors - Integrity constrains
I am new with database and I am using cursors.
I have three tables:
new_customers: customer_id, date, description, account, type, amount
customers: customer_id (PK)(FK), account(PK)(FK), type, amount
customers_history: customer_id(PK), date, description
I want to grab all the information that is on new_customers and update / save it on customers and customers_history. I have to do it with cursos (which i don't fully undestand)
My first step was with the new_customers and customers table:
CURSOR c_new_customers IS
SELECT customer_id, date, description, account, type, amount
FOR rec_newC IN c_new_customers LOOP
INSERT INTO TRANSACTION_DETAIL (customer_id, account, type, amount)
VALUES (rec_newC.customer_id, rec_newC.account, rec_newC.type, rec_newC.amount);
But I have the error ORA- 02291 Integrity constraint I know that this means that the data that I am trying to insert is an PK in another table but I don't know how to fix it.
I will appreciate the help