Re: Using psql's \prompt command - Mailing list pgsql-general

From David G. Johnston
Subject Re: Using psql's \prompt command
Date
Msg-id CAKFQuwa3okeZQx95HEKPB322zTPYKOyVhfiCBfkrxTnF5y=Z7w@mail.gmail.com
Whole thread Raw
In response to Re: Using psql's \prompt command  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-general
On Thu, Jan 30, 2025 at 3:46 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thu, Jan 30, 2025 at 3:44 PM David G. Johnston <david.g.johnston@gmail.com> wrote:
On Thu, Jan 30, 2025 at 3:38 PM Rich Shepard <rshepard@appl-ecosys.com> wrote:
On Thu, 30 Jan 2025, Rich Shepard wrote:

> Thank you. I'll look into using the \set command.

My web searches find many examples of using the \set command, but none
getting user input with \prompt.

Please point me to a reference where I can learn how to get the user input
string into the script.

That is what \prompt is for.  You have the correct meta-command, you were capturing user input just fine.  Read about how to use variables in queries for the part you are missing.

Specifically the section of the psql docs titled:

SQL Interpolation


Or:

Advanced Features
- Variables

David J.

pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Using psql's \prompt command
Next
From: Rich Shepard
Date:
Subject: Re: Using psql's \prompt command