Actually the best way to handle this, is a unique constraint on the data table.
If this is not an option you have to do a select on the on the table to check for results.
If there are now rows returned you may insert.
Using MySQL DB there's another solution. You can do
INSERT INTO table (a,b,c) VALUES (1,2,3)
ON DUPLICATE KEY UPDATE c=c+1;
Don't know if this syntax also aplies to other DBEs.