Subject AW: AW: [Firebird-Java] Do I need to commit every transaction if I'm using jaybird?
Author Steffen Heil
Hi

> As I wrote, I have no example for now.

Oh, you have, see below... :D

> > They work or they are rolled back by some exception.
>
> True. But work of a single statement. Procedure is also
> considered a single statement. All this is controlled by
> internal savepoints.

Okay, hence this is down to the definition of "single statement".

> > So, can you explain what you ment and give any example?
>
> Sure, theoretical example would be:
>
> Statement stmt = con.createStatement();
> stmt.execute("INSERT INTO bla VALUES(1); INSERT INTO bla
> VALUES(2); UPDATE bla SET id = 2");

This in my POV are three statements. Not one.
This may be one JDBC statement, but these ARE three SQL statements.

But I see, what you mean.

> But currently Firebird does not support this (for example,
> DB2 does), so nothing to worry for now (but maybe there is
> some wierd example that I do not know).

I believe that there CANNOT be such a statement, since sql is ment to
execute statements atomically. The internal savepoints you refered to are
exactly there to have that all-or-nothing-logic.
So, if you execute single sql statements, you can only end up having done
everything OR every partiall modification is rolled back by the engine, so
you have nothing. Commiting nothing is not a problem, so the auto-commit of
the JDBC-driver is not a problem.

The lession, I learned from that some time ago: Put any sequence of changes
into a stored procedure.
Executing a stored procedure is atmoic, so no problem....

Regards,
Steffen


[Non-text portions of this message have been removed]