Re: Use a TEXT string which is an output from a function for executing a new query in postgres

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: Roy Blum <blumroy(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Use a TEXT string which is an output from a function for executing a new query in postgres
Date: 2015-01-08 00:08:00
Message-ID: 54ADCA60.1050904@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 01/08/2015 02:12 AM, Roy Blum wrote:
> I have created a function *myresult()* that receives as input Table
> name, and a Prefix, it then creates an SQL one liner command to SELECT
> from the specified table only the columns that share the designated
> prefix. It output a string which is basically the desired SQL command.
> My function is as follows and I show how I call it as well:

This is reposted from Stack Overflow, where it has already been pretty
comprehensively answered.

http://stackoverflow.com/q/27808534/398670

http://stackoverflow.com/q/27824725/398670

As suggested earlier - return a refcursor.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Krawczyk 2015-01-11 12:29:35 pg_stat_acvtivity
Previous Message Rob Sargent 2015-01-07 18:16:54 Re: Use a TEXT string which is an output from a function for executing a new query in postgres