![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
If this is not an appropriate ng, let me know and please redirect me. I am not sure if my question is Oracle specific or if it is OK to ask Oracle specific questions here. I have a many to many relationship. I've learned that when that happens you are to make an intermediate table between the two. So, I've got a table with 2 fields, an ID from the one side and an ID from the other. In my application I am writing all the upserts for all my entities. In doing so, I've come across my first upsert of this type. Normally, my upserts looks like this: BEGIN UPDATE PROSPECT_INTERESTS SET PERSON_ID = ProspectID, INTEREST_ID = InterestIDWHERE PERSON_ID = :PersonID AND INTEREST_ID = InterestID;IF SQL%NOTFOUND THEN * *INSERT INTO PROSPECT_INTERESTS * * * (PROSPECT_ID, INTEREST_ID) * * * VALUES * * * ( ProspectID, InterestID);END IF; END; In this case, the update statement makes no sense, because all there is to update is the primary key which identifies the thing in the first place. So, what is the proper way to say "If it doesn't exist already insert it, otherwise do nothing?" |
![]() |
| Thread Tools | |
| Display Modes | |
| |