Chapter 4. Returning Structured Data

In the previous chapter, we saw functions that return single values. These functions return either a "scalar," simple type such as an integer, text, or data; or a more complex type, similar to a row in the database table. In this chapter, we will expand these concepts and show you how to return your data to the client in more powerful ways.

We will also examine the following topics:

  • Differences between SETOF scalars, rows, and arrays
  • Returning CURSORs, which are kind of "lazy" tables, that is, something that can be used to get a set of rows, but which may not have actually evaluated or fetched the rows yet, as the modern world is not about rigid table-structured data
  • Ways to deal with more complex data structures, ...

Get PostgreSQL Server Programming - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.