5.8.3 • Published 4 years ago

ut-port-postgres v5.8.3

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
4 years ago

Postgres Port: ut-port-postgres

Returning multiple result sets

If there is need to return data from several unrelated queries, the following pattern can be used. If we have the queries q1 and q2 (each one is any valid select statement represented with SELECT 1 and SELECT 2 below), then the following can be executed:

WITH
    q1 AS (SELECT 1),
    q2 AS (SELECT 2)
SELECT
    (SELECT json_agg(q1) FROM q1) AS q1,
    (SELECT json_agg(q2) FROM q2) AS q2

This query can be used as result from a function with the following signature:

CREATE FUNCTION f1() RETURNS TABLE(q1 json, q2 json) AS

The result returned by the port will be JSON with the following structure:

{
    "q1":[],
    "q2":[]
}

This basically returns two result sets as properties in one object. Each result set is array of objects, where each object represents one row from the query.

5.8.3

4 years ago

5.8.2

5 years ago

5.8.1

5 years ago

5.8.0

5 years ago

5.7.12-noWhen.0

7 years ago

5.7.11

7 years ago

5.7.10

7 years ago

5.7.9

7 years ago

5.7.8

7 years ago

5.7.7

7 years ago

5.7.6

7 years ago

5.7.5

7 years ago

5.7.4

7 years ago

5.7.3

8 years ago

5.7.2

8 years ago

5.7.1

8 years ago

5.7.0

8 years ago

5.6.6

8 years ago

5.6.5

8 years ago

5.6.3

8 years ago

5.6.2

8 years ago

5.6.1

8 years ago

5.6.0

8 years ago

5.5.0

8 years ago

5.4.2

8 years ago

5.4.1

8 years ago

5.4.0

8 years ago