Skip to main content

Tree Calculations with Recursion

  • Chapter
  • First Online:
Practical Oracle SQL
  • 1398 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Kim Berg Hansen

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

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

Publish with us

Policies and ethics