Abstract
Any procedural language supports some form of recursion. A procedure or function can call itself – if needed repeatedly until some condition has been reached. Typically they’ll also support iteration, which is related but not quite the same. SQL deals with sets of rows, not procedural logic, so how can you do recursion in SQL? It still concerns itself with sets of rows: first find a set of rows; then based on that set of rows, you apply some logic to find a second set of rows; then based on that set of rows, you apply the logic again (recursively) to find a third set of rows; and so you keep on going until you find no more rows. In this chapter the primary focus is on SQL recursion in the form of recursive subquery factoring that is the most directly applicable method of recursion in SQL.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2020 Kim Berg Hansen
About this chapter
Cite this chapter
Berg Hansen, K. (2020). Tree Calculations with Recursion. In: Practical Oracle SQL. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-5617-6_4
Download citation
DOI: https://doi.org/10.1007/978-1-4842-5617-6_4
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-5616-9
Online ISBN: 978-1-4842-5617-6
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books