I have two table: table_1 and table_2. In these tables there are two columns: p_code (varchar2) and o_code (varchar2) and both of them primary key. So we have:
table_1.p_code,
table_1.o_code,
table_2.p_code,
table_2.o_code
I want to copy table_2 into table_1 but there may be some same rows that already exist in table_1. I thought i could handle this situation with function or procedure but i couldnt. How can i handle this?
By the way: Two Example table and columns:
Table_1:
P_code O_code
C123 PREP100
C123 PREP101
Table_2:
P_code O_code
C123 PREP101
C123 PREP102
I want to insert table_2 into Table_1 but C123 PREP already exist in Table_1. I thought i could sperate the last three char, trun into number, increase one, turn into varchar2, and see if exist in table_1. But i couldnt write the sql procedure or function for it...