pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: M Sarwar <sarwarmd02@outlook.com>
To: pgsql-admin@lists.postgresql.org <pgsql-admin@lists.postgresql.org>
Subject: Re: Like to RETURN SQL results set
Date: Thu, 28 Mar 2024 10:19:40 +0100
Message-ID: <2ed4638d9de6042890f9b95aa596513ffe163416.camel@cybertec.at> (raw)
In-Reply-To: <DM4PR19MB5978E0422300C922982974EBD3342@DM4PR19MB5978.namprd19.prod.outlook.com>
References: <PH2P110MB0922721CBEE6FECB56E1A0F7FF34A@PH2P110MB0922.NAMP110.PROD.OUTLOOK.COM>
	<DM4PR19MB5978E0422300C922982974EBD3342@DM4PR19MB5978.namprd19.prod.outlook.com>

On Wed, 2024-03-27 at 20:40 +0000, M Sarwar wrote:
> I am writing a dynamic function in which number of columns to be retrieved change
> depending on the parameter values passed while invoking the function.
> I am using CROSSTAB in the dynamic SQL.
> Once I prepare a dynamic SQL and I execute, I want the entire result set from
> the executed SQL to be returned to function RETURN.
> Is this possible? If yes, can you please point me to some examples.

No, this is not possible, unless you declare the function as "RETURNS SETOF record".
But then you have to specify the column list when you use the function, e.g.:

  SELECT * FROM func() AS (c1 integer, c2 text)

Yours,
Laurenz Albe





view thread (9+ messages)  latest in thread

Message-ID: <2ed4638d9de6042890f9b95aa596513ffe163416.camel@cybertec.at>
Permalink:  ../2ed4638d9de6042890f9b95aa596513ffe163416.camel@cybertec.at/
Also on:    postgresql.org/message-id/2ed4638d9de6042890f9b95aa596513ffe163416.camel@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: laurenz.albe@cybertec.at, sarwarmd02@outlook.com, pgsql-admin@lists.postgresql.org
  Subject: Re: Like to RETURN SQL results set
  In-Reply-To: <2ed4638d9de6042890f9b95aa596513ffe163416.camel@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox