brgdotnet
asked on
Best way to insert if record does not exists?
I need to check if one instance of a record exists in a table before inserting the records. As I don't want to insert the record twice. I need an Oracle expert to show me an example of how best to do that?
ASKER
I am looking for a real world example?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@Pallavi,
I believe the question involves a single table. MERGE isn't really set up to work on a single table. You can get it to work but I'm not sure it is the best way to answer this question.
I believe the question involves a single table. MERGE isn't really set up to work on a single table. You can get it to work but I'm not sure it is the best way to answer this question.
>>I am looking for a real world example? <<
Show us some sample data that exists in your world with what you expect the final result to be and it will help us better understand your need.
Show us some sample data that exists in your world with what you expect the final result to be and it will help us better understand your need.
@brgdotnet,
Can I ask why you accepted a post that doesn't appear to help answer your question?
Can I ask why you accepted a post that doesn't appear to help answer your question?
@slightwv (䄆 Netminder)
I think @brgdotnet might have tried the solution and it might be working for him. Therefore, he has accepted the solution. If you have some better solution than this, you can go forward and suggest,
I think @brgdotnet might have tried the solution and it might be working for him. Therefore, he has accepted the solution. If you have some better solution than this, you can go forward and suggest,
I always question when ALL participants get accepted/assisted. If MERGE worked and answered the question then I shouldn't get points. If it was a unique constraint/primary key then you shouldn't.
I don't see splitting points in this question.
I don't see splitting points in this question.
Worst case: Select from the table first and see if you get rows. If not, then insert.
If you can provide a little more information showing what you are trying to achieve, we can probably provide more information.