Subject Re: [Firebird-Java] Re: No SavePoints for FB 1.0x?
Author Roman Rokytskyy
> So, that's your choice whether to wait for error code for failed
> insert on the client or use stored procedure that simply ignores
> that error. In case of procedure your call will always succeed.

Some more tips:

executeUpdate() in PreparedStatement is at least two calls:

isc_dsql_execute2(params) : isc_status_vector - perform insert
isc_dsql_info(stmtHandle) : info_vector - get number of inserted rows

executeUpdate(String) in Statement is at least three calls:

isc_dsql_prepare(sql) - prepare sql statement
isc_dsql_execute2(params) : isc_status_vector - peform insert
isc_dsql_info(stmtHandle) : info_vector - get number of inserted rows
(also there will be isc_close_statement)

If you write your procedure to return a value 1 if insert succeeded, and 0
if not, and use CallableStatement, you get only one network call per insert,
namely isc_dsql_execute2. The value is returned as response to the call.

Also, if duplicate key exception happens in the database, driver generates
GDSException instance and might perform some internal processing that is not
done in case of normal execution.

So, using the stored procedure might be the fastest way to do an insert,
ignore the duplicate key exception and tell the application whether insert
has succeeded or not.