Book Image

PostgreSQL Server Programming

Book Image

PostgreSQL Server Programming

Overview of this book

Table of Contents (21 chapters)
PostgreSQL Server Programming Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

A summary of the RETURN SETOF variants


You learned that you can return table-like datasets from a function using one of the following:

RETURNS

RECORD structure

INSIDE function

SETOF <type>

This is obtained from the type definition

DECLARE row variable of the ROW or RECORD type

ASSIGN to row variable

RETURN NEXT var;

SETOF <table/view>

This is the same as the table or view structure

 

SETOF RECORD

Dynamic using AS (name type, …) at call site

 

SETOF RECORD

This uses the OUT and INOUT function arguments. Assigned to the OUT variables

RETURN NEXT ;

TABLE (...)

This is declared inline, in parentheses, after the TABLE keyword and is converted to the OUT variable for use in functions. It is assigned to the OUT variables from the TABLE(...) part of the declaration.

RETURN NEXT ;