Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cursors and Insert

Author  Topic 

lektor
Starting Member

1 Post

Posted - 2013-10-16 : 22:14:35
Hi Everyone;

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:


DECLARE
CURSOR c_new_customers IS
SELECT customer_id, date, description, account, type, amount
FROM NEW_TRANSACTIONS;



BEGIN
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);
END LOOP;

END;
/


But I have the error ORA- 02291 Integrity constraint and I don't know how to fix it

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-10-16 : 23:19:32
That looks like an Oracle error. This site is specific to MS Sql Server. Try a site that supports Oracle. It think DBForums is one.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -