Abhi
Abhi

Reputation: 334

Is Recursion possible in DB2 PL SQL Stored Procedure?

I am trying to build a recursive Stored Procedure in DB2 PL SQL. But a little late in the game did I realize that it would throw an undefined reference error. So is recursion not possible in DB2 PL SQL?

Upvotes: 1

Views: 693

Answers (1)

Preet Sangha
Preet Sangha

Reputation: 65496

From the IBM Devworks by Serge Rielau and Rick Swagerman

There are multiple ways in which DB2 supports recursion in SQL. One of which is recursion using the ANSI SQL recursive UNION ALL approach. The other approach is using the CONNECT BY clause.

You need to use Modules or dynamic SQL according to this blog.

Upvotes: 2

Related Questions