That depends on the DBMS you are using. I know Oracle so I can only
tell you how to go about this with PL/SQL.
In PL/SQL your could have a stored function that could tell
your script if a record exist or not so that your script could
choose either to do a insert or an update. You could also just
use a stored procedure like the one I mentioned earlier and just
add your fields to the parameter list. You could also do everything
from your script. Your script could do the update and if the row count
is zero that means your script needs to do an insert.