Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3nZr-0002nN-HL for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 20:32:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i3nZq-0002jS-1W for pgsql-general@arkaria.postgresql.org; Fri, 30 Aug 2019 20:32:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3nZp-0002jL-Lf for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 20:32:57 +0000 Received: from mail-pg1-x52f.google.com ([2607:f8b0:4864:20::52f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3nZm-00085H-4W for pgsql-general@lists.postgresql.org; Fri, 30 Aug 2019 20:32:57 +0000 Received: by mail-pg1-x52f.google.com with SMTP id n9so4102517pgc.1 for ; Fri, 30 Aug 2019 13:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=u8KiWXBYKHDhlftLeJBleF0ewoDMBf5pS2xEW9NCokg=; b=tk7NOLnQ4ETJj3l9TaWVv/2UCEKMZfgRjXDAKUTbUZVvXrGD2qoWlPHnEI5p5I5+x7 alADwVA+E/lOz43I3UJbgQImGDY28O59JRz1hVkZmaq8YZg+qCk863T+LqhwLEaJal0Z V9nSlg1sdb0AaTje/+RXnCmbefNCpf+DWj8mn99/cniwmPLuHwbyVeMh38E7Ls2h1XOD e6YR1T6XmwuWtqqvhSYoEuGe+krCWQhVk1hEFkt5BRQEIT0geWrd3xyzJaMpleFYp+Cf 40kS8iNkupDvdOvRRjj/A5w+JA49p/l9+GGQaDp3tERV6hUlNWr50nR9aWko6MMxCRY4 QwKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=u8KiWXBYKHDhlftLeJBleF0ewoDMBf5pS2xEW9NCokg=; b=MwONEJ9ReWwlDAeAYQWWxdM5HcZbXGb4JyItPP6YCKSFAYkI8gGtL+GCu9Kf/6pSmY 75+K5fUtbrTvsb3cDh+k4hwUkFqnL4gOohgUsh1Due3XIk6ibUrDFsMsH7wLh0bEyAj0 bqM0hXgafW2YkzIWcfIbgC7UqLuVUOKo5JMyG0yJ0RJKnDS1si6QaL92M5QZbRZQNy/n V9wlI3Zxrkpvj2BGpoWmQLlCrEMlOSO9LZ9JWE/OdseJooGYL8CH3efdIwXpIhnLQmT1 wsJrHlsqz0/llmmO7OYUnDliXbCcnhg9UHR3lm8foaYSqEqNrLUwY18PsWaLtLW3i9kn 4QvA== X-Gm-Message-State: APjAAAWBYpb4GTEHuCDl16fOxpxr/KxGl5uOs0TbNLRZqiMwteZMFz6r s4i58OqFlVL66YGm450Ix6P17JLpGaw= X-Google-Smtp-Source: APXvYqwUFZsTGCmVf9FyfvTrJh1emG4/CltuK7jfkDkckJ+LS9ku5rtPEJ6yUYAPel1c7EfEwlA+nA== X-Received: by 2002:a62:1955:: with SMTP id 82mr4474682pfz.256.1567195752509; Fri, 30 Aug 2019 13:09:12 -0700 (PDT) Received: from [10.106.131.0] ([155.100.47.0]) by smtp.gmail.com with ESMTPSA id j1sm5665192pgl.12.2019.08.30.13.09.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Aug 2019 13:09:11 -0700 (PDT) From: Rob Sargent Message-Id: <97A82FDB-C59B-4B7E-8B4E-788E27E50322@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_72EBCCC7-4350-4B03-9016-21A0EA77D21E" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: Returning a table from a function, that requires multiple selects? Date: Fri, 30 Aug 2019 14:09:10 -0600 In-Reply-To: <20190830200315.GA28175@panix.com> Cc: pgsql-general@lists.postgresql.org To: stan References: <20190830200315.GA28175@panix.com> X-Mailer: Apple Mail (2.3445.104.11) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_72EBCCC7-4350-4B03-9016-21A0EA77D21E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 30, 2019, at 2:03 PM, stan wrote: >=20 > I need to encapsulate, what are basically 2 related function calls = into a single > function. The result of each of th calls is a date type. >=20 > y current thinking is to return a 2 row table with the 2 dates in it. = But, I seem to > be having issues getting this to work. >=20 > Is it possible for a function to return a table with results from = multiple > queries? >=20 > --=20 > "They that would give up essential liberty for temporary safety = deserve > neither liberty nor safety." > -- Benjamin Franklin >=20 >=20 If the two queries are identical in returned columns you might be able = to use UNION: select f1.* from first_query as f1 UNION select f2.* from second_query = as f2; You can=E2=80=99t do any processing of f1 or f2. --Apple-Mail=_72EBCCC7-4350-4B03-9016-21A0EA77D21E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Aug 30, 2019, at 2:03 PM, stan <stanb@panix.com> = wrote:

I need to encapsulate, what are basically 2 related function = calls into a single
function. The result of each of th = calls is a date type.

y current thinking is = to return a 2 row table with the 2 dates in it. But, I seem to
be having issues getting this to work.

Is it possible for a function to return a table with results = from multiple
queries?

--
"They that would give up essential liberty for temporary = safety deserve
neither liberty nor safety."
= = = = = = -- Benjamin Franklin


If the two queries are = identical in returned columns you might be able to use UNION:
select f1.* from first_query as f1 UNION select f2.* from = second_query as f2;

You can=E2=80=99t do any processing of f1 or f2.

= --Apple-Mail=_72EBCCC7-4350-4B03-9016-21A0EA77D21E--