Common table expressions are recursive when they are executed repeatedly, with each execution returning additional rows until the complete result set is retrieved. You can make a common table expression recursive by inserting the RECURSIVE keyword immediately following WITH in the WITH clause. A single WITH clause may contain multiple recursive expressions that can be both recursive and non-recursive.
Recursion provides an easier way of traversing tables that represent tree or tree-like data structures. Without using recursive expressions, the only way to traverse such a structure in a single statement is to join the table to itself once for each possible level.
Discuss this page in DocCommentXchange.
|Copyright © 2012, iAnywhere Solutions, Inc. - SQL Anywhere 12.0.1|