# SQLCODE -724: Too many levels of cascading

Source: https://wndsoftware.com/mainframe-errors/sqlcode-724

### SQLCODE -724: Too many levels of cascading

SQLCODE -724 (SQLSTATE 54038) means a chain of triggers, user-defined functions or stored procedures calling each other would go deeper than 16 levels. Db2 stops the statement and rolls back the SQL the whole chain ran.


#### Other names for this code

Also written as `SQL -724`, `SQLCODE=-724`, `SQLCODE = -724`, `db2 -724`, `sqlstate 54038`, `SQL0724N`, `maximum level of indirect SQL cascading`.


### What it means

One SQL statement can set off others. An UPDATE fires a trigger, the trigger calls a procedure, the procedure updates another table that has its own trigger, and so on. Referential delete rules join in too, since a cascaded delete can fire delete triggers on the child table. Db2 calls this indirect SQL cascading and allows at most 16 levels.

When the next activation would be the 17th level, Db2 returns -724. The message gives the object type (TRIGGER, FUNCTION or PROCEDURE) and the name of the object that would have run at that level. The original statement doesn't run, and the SQL done by the chain is rolled back. Actions outside Db2 that a routine already took, such as sending a message, aren't undone.

A real chain 16 deep is rare. Most of the time -724 means a loop.


### Common causes

- A trigger updates its own table, which fires the same trigger again, with nothing to stop it.
- Two tables keep each other in step with triggers. An update to A updates B, whose trigger updates A, and so on.
- A stored procedure or function calls itself, directly or through another routine, without an end condition.
- A long cascade of delete rules fires a delete trigger on each table it passes through.


### How to find the problem

- Take the object type and name from the message. That's where the chain broke, not necessarily where the loop starts.
- List the triggers on each table involved with `SELECT SCHEMA, NAME, TBNAME, TRIGTIME, TRIGEVENT FROM SYSIBM.SYSTRIGGERS WHERE TBNAME = 'ACCT_BAL'`, and read their text.
- Follow the chain from the original statement. Write down which trigger or routine each step activates until you see a table or routine come round again.
- For delete cascades, check DELETERULE C rows in SYSIBM.SYSRELS for the tables in the chain.


### How to fix it

- Give recursive triggers a WHEN clause that stops them, for example firing only when the column really changed.
- For two tables kept in step, let only one side drive the change, or have the trigger skip rows that already match.
- Add an end condition to recursive procedures and functions.
- If the chain is simply long, flatten it so fewer triggers and routines call each other.


### IBM documentation

[IBM documentation: -724](https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=codes-724). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -723 Error in a triggered SQL statement Read →](https://wndsoftware.com/mainframe-errors/sqlcode-723)
[SQLCODE -577 Routine not allowed to modify data Read →](https://wndsoftware.com/mainframe-errors/sqlcode-577)
[SQLCODE -579 Routine not allowed to read data Read →](https://wndsoftware.com/mainframe-errors/sqlcode-579)
[SQLCODE -532 Delete restricted by a foreign key Read →](https://wndsoftware.com/mainframe-errors/sqlcode-532)
[SQLCODE -911 Deadlock or timeout, rolled back Read →](https://wndsoftware.com/mainframe-errors/sqlcode-911)

### Questions


#### What is the limit?

16 levels of triggers, functions and procedures activating each other. The object named in the message is the one that would have been 17th.


#### Is everything rolled back?

The SQL done by the triggers, functions and procedures in the chain is rolled back and the original statement doesn't run. Anything a routine did outside Db2 stays done.


#### Is -724 the same on Db2 for LUW?

Yes. Db2 for LUW reports SQL0724N with SQLSTATE 54038 and the same limit of 16 levels.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE -723](https://wndsoftware.com/mainframe-errors/sqlcode-723) · [SQLCODE -802](https://wndsoftware.com/mainframe-errors/sqlcode-802)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
