Subject | Re: [Firebird-Java] Re: No SavePoints for FB 1.0x? |
---|---|
Author | Roman Rokytskyy |
Post date | 2005-01-07T19:46:29Z |
> Thanks Roman but I'm not sure I understand this, the BEGIN..ENDAnd it should be "null". :) The SQLCODE -803 is "duplicate key exception",
> looks null to me.
> WHEN SQLCODE -803 DO BEGIN
> END;
and you want to ignore it, right?
> Just out of curiosity and moving on from the stored procedure, whatIf you're handling the DuplicateKeyException in your application, what's the
> is the behavior if I did this?
>
> for ( Iterator it = records.iterator(); it.hasNext(); )
> {
> Record record = it.next();
>
> try
> {
> insertIntoOneTable( con, record );
> }
> catch ( DuplicateKeyException e )
> {
> // just continue
> }
> }
>
> con.commit();
>
> public void insertIntoOneTable( con, record ) throws ...
> {
> // this just does an insert into a single table
> }
>
> What would happen here?
point to have savepoints? Each duplicate key invalidates only that insert,
not the inserts done previously. You can successfully continue your batch
(but not in the JDBC sense - java.sql.Statement or
java.sql.PreparedStatement batches are automatically rolled back).
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.
Roman