Utilizing composite types

In most other database systems, stored procedures are only used with primitive datatypes such as integer, numeric, varchar, and so on. However, PostgreSQL is very different. You can basically use all datatypes available to you. This includes primitive as well as composite and custom types. There are simply no restrictions as far as datatypes are concerned. To unleash the full power of PostgreSQL, composite types are highly important and are often used by extensions which can be found on the internet.

The following example shows how a composite type can be passed to a function and how it can be used internally. Finally, the composite type will be returned again:

CREATE TYPE my_cool_type AS (s text, t text); CREATE ...

Get Mastering PostgreSQL 10 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.