From the code (Java) I wish to make sure that a row is available within the database (DB2) after my code is performed.

My code now does a choose and when no outcome is came back it will an place. I truly can't stand this code because it exposes me to concurrency issuses when running inside a multi-threaded atmosphere.

What I must do would be to put this logic in DB2 rather than during my Java code. Does DB2 come with an "place-or-update" statement? Or anything enjoy it will be able to use?

For instance:

insertupdate into mytable values ('myid')

One other way to do it might most likely be to allways perform the place and catch "SQL-code -803 primary key already is available", but I must avoid when possible.

Yes, DB2 has got the MERGE statement, which is going to do an UPSERT (update or place).

MERGE INTO target_table USING source_table ON match-condition


Please also make reference to the thread Attempting to avoid -803 in DB2 place in here.