Re: gexec from command prompt?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: gexec from command prompt?
Date: 2023-01-12 18:04:08
Message-ID: 20230112180408.b7hhh3ypdnthpa7i@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-01-12 18:41:29 Re: gexec from command prompt?
Previous Message Pavel Stehule 2023-01-12 17:33:59 Re: gexec from command prompt?