Subject Re: [Firebird-Java] No SavePoints for FB 1.0x?
Author Roman Rokytskyy
> I'm not using FB 1.5 but need something akin to save points.
> Basically, I am inserting a bunch of data using a transaction. If
> one of those inserts results in a duplicate key exception, I'd like
> to continue processing the batch but without that one insertion.
>
> Is there a way to do something like this without savepoints? I'd
> really like to avoid committing each insert individually or (worse
> yet) querying for an existing record before each insert.
> Suggestions?

Use stored procedures. Each SP has internal savepoint, which allows you to
handle exceptions correctly:

CREATE PROCEDURE my_insert_proc(param1 integer, param2 char(1), ...)
AS BEGIN
INSERT INTO my_table(col1, col2) VALIES(:param1, :param2);

WHEN SQLCODE -803 DO BEGIN
END;
END

And then instead addBatch("INSERT INTO ...") you use addBatch("EXECUTE
PROCEDURE ...") (JayBird does not support batch callable statements, but you
can use either normal Statement or PreparedStatement batchs).

Roman