'AUTONOMOUS_TRANSACTION in DB2 Luw

I have an application migrated from oracle to db2. There is a package defined where some of the procedures are using pragma autonomous transaction to maintain some logs. The package got compiled successfully, but the logging isn't working as it was working with oracle. Is there any special way in DB2 to make it work? I am using Dbeaver to compile my packages.



Solution 1:[1]

Db2-LUW supports autonomous procedures.

When your procedure is written with SQL PL syntax, you specify that a procedure is autonomous by using that keyword on the CREATE PROCEDURE statement (it is not the default)

IBM documents this on this link.

Solution 2:[2]

It's hard to say what is wrong without seeing your code. Db2 has limited support for the AUTONOMOUS_TRANSACTION pragma (see page 104 of this Redbook), provided that Oracle compatibility features are enabled in your database. -- it only works at the stored procedure level.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mao
Solution 2 mustaccio