Java Prepared Statement with multiple arguments



Hi,

I need to insert data into a table only if that data does not already
exist.

So I want to do something like

IF NOT EXIST (SELECT * FROM MyTable WHERE MyColumn = '?') INSERT INTO
MyTable (MyColumn) VALUES ('?')

In this example there is only one column, but in my real table I have
about 10 columns.

So I can create a prepared statement to do this, but since I use two
?'s for each column (one for the select and another for the insert) I
have to set each column value twice.

Am I using this right? Is there a better way to do this?

THANKS!
John

.



Relevant Pages