I need to write a view that does a merge insert/update.
When inserting, I need to insert id.
This id is also being inserted by random number generator in another program ( which I can’t change ).
I wanted to do max(id) + 1, but not sure if that is a good idea. Could you suggest any better solutions for this problem?
or
How about using with id as ( dbms_random …. ) do a
select * from table where id = ?
if row is not found, I will insert this id otherwise, I will generate another random and do a select.
if this is for a Primary Key – then how about generating negative numbers for your part of the app (using a sequence) and leaving the random number wizardry in the positives…