| Firebird Documentation Index → Firebird 2.5 Release Notes → Procedural SQL (PSQL) → Autonomous Transactions |
![]() |
Tracker reference CORE-1409.
This new implementation allows a piece of code to run in an autonomous transaction within a PSQL module. It can be handy for a situation where you need to raise an exception but do not want the database changes to be rolled back.
The new transaction is initiated with the same isolation level as the one from which it is launched. Any exception raised in a block within the autonomous transaction will cause changes to be rolled back. If the block runs through until its end, the transaction is committed.
Because the autonomous transaction is independent from the one from which is launched, you need to use this feature with caution to avoid deadlocks.
Syntax Pattern
IN AUTONOMOUS TRANSACTION
DO
<simple statement | compound statement>
Example of Use
create table log (
logdate timestamp,
msg varchar(60)
);
create exception e_conn 'Connection rejected';
set term !;
create trigger t_conn on connect
as
begin
if (current_user = 'BAD_USER') then
begin
in autonomous transaction
do
begin
insert into log (logdate, msg) values (current_timestamp, 'Connection rejected');
end
exception e_conn;
end
end!
set term ;!
| Firebird Documentation Index → Firebird 2.5 Release Notes → Procedural SQL (PSQL) → Autonomous Transactions |