Link to home
Start Free TrialLog in
Avatar of aaba646
aaba646Flag for United States of America

asked on

Compare two cursors and Insert or Update

Hi ,

I have cursor1 which has col1A,col2A,col3A,col4A and cursor2 with col1B,col2B,col3B,col4B
Now i have to compare each record from cursor1 with corresponding fields with cursor2 records and if found then update and if not found insert the new record into table xyz.

The cursor1 would bring the records from table abc whereas cursor2 would bring the records from xyz table.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of hans_vd
hans_vd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of awking00
Your question is a little ambiguous. Comparing two cursors can be a performance nightmare having to fetch a row from the first cursor then compare it to all of the rows from the second cursor and repeating this for all of the rows in the first cursor. Your solution might be as simple as using the merge that hans_vd shows, although I suspect that there are numerous where clauses in the select statements of your cursors that may complicate things. Post the select statements for your cursors and the update and insert statements here and we can see if there is an easier means of accomplishing your intent.