Subject Transaction concurrency
Author Gerevich Janos
I am using firebird(1.5.1) with Jaybird JDBC(1.5.5) with autocommit ON

I am inserting records that all have a timestamp

What I want to do, is that noone can insert a record, whose timestamp
isn't disjunct with all inserted timestamps (take table reservations:
you can't reserve a table from 20 to 23 if that table is already
reserved from 18 to 20:30. These reservations are not disjunct, because
they coincide from 20 to 20:30)

From java I allways call a stored procedure to insert a timestamped record

My stored procedure is made of two parts:
first part- checks if there are any conflicting records
second part- throws exception if there are conflicting records,
otherwise insert the given record

Now what I though was that these two parts are handled as ONE atomic
operation, but after some testing I may be wrong

Just to check if the bug is in my program: does firebird handle a stored
procedure as ONE atomic operation?

(if not, inconsistency can occur when client A just finishes part 1 of
the procedure checking for confliscting records. Then client B finishes
part 2 of the procedure before client A gets to it's second part. B just
inserted a record , that conflicts with client A, but client A will not
check again, it just inserts it's record after all this)