pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Ron <ronljohnsonjr@gmail.com>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: gexec from command prompt?
Date: Thu, 12 Jan 2023 19:04:08 +0100
Message-ID: <20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql> (raw)
In-Reply-To: <00a37956-d2b1-3749-9747-66d0d562ac90@gmail.com>

On 2023-Jan-12, Ron wrote:

> Postgresql 12.11
> 
> This might be more of a bash question, or it might be a psql vs engine problem.
> 
> I want to run this query using psql from a bash prompt:
> select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name)
> from dba.table_structure
> order by table_name\gexec

Yeah, what I use in these cases is something like

echo "select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name, table_name)
from dba.table_structure
order by table_name \gexec" | psql -f-


-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"El hombre nunca sabe de lo que es capaz hasta que lo intenta" (C. Dickens)





view thread (4+ messages)  latest in thread

Message-ID: <20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql>
Permalink:  ../20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql/
Also on:    postgresql.org/message-id/20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@alvh.no-ip.org, ronljohnsonjr@gmail.com
  Subject: Re: gexec from command prompt?
  In-Reply-To: <20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql>
  References: <00a37956-d2b1-3749-9747-66d0d562ac90@gmail.com> <20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql>

* 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