Re: gexec from command prompt?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
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 17:33:59
Message-ID: CAFj8pRB5XSs5Cuxe935qd4jTQA_Ucw+tVgP+RbEcjuVGBvqCoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

čt 12. 1. 2023 v 18:25 odesílatel Ron <ronljohnsonjr(at)gmail(dot)com> napsal:

> 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
>
> Thus, I added an extra back
>
> $ psql sides -atXc "select format('SELECT ''%s'', MIN(part_date) FROM
> %s;',
> table_name, table_name) from dba.table_structure order by table_name limit
> 5\\gexec"
> select format('SELECT ''%s'', MIN(part_date) FROM %s;', table_name,
> table_name) from dba.table_structure order by table_name limit 5\gexec
> ERROR: syntax error at or near "\"
> LINE 1: ...) from dba.table_structure order by table_name limit 5\gexec
>
> Removing "\\exec" from the statement, and appending -c "\\gexec" to the
> psql
> command technically worked, but did not run the commands.
>

I don't know why, but \g* commands don't work from the -c option. But in
this case it is not necessary

you can psql -c "xxx" | psql

Regards

Pavel

>
> --
> Born in Arizona, moved to Babylonia.
>
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2023-01-12 18:04:08 Re: gexec from command prompt?
Previous Message Ron 2023-01-12 17:25:00 gexec from command prompt?