public inbox for [email protected]  
help / color / mirror / Atom feed
From: Rich Shepard <[email protected]>
To: [email protected]
Subject: Using psql's \prompt command
Date: Thu, 30 Jan 2025 13:47:59 -0800 (PST)
Message-ID: <[email protected]> (raw)

I want to use the \prompt command to get user input for a query. My script
fails:

-- Display person_nbr, lname, fname, direct_phone, email from people, contact history from contacts.

-- prompt for person_nbr before selecting rows:
\prompt 'Enter person_nbr: ' store

select p.person_nbr, p.lname, p.fname, p.direct_phone, p.email, c.contact_date, c.contact_time, c.contact_type, c.notes
from people as p natural inner join contacts as c
where person_nbr = store
order by c.contact_date, c.contact_time;

# \i person_view.sql
Enter person_nbr: 468
psql:person_view.sql:9: ERROR:  column "store" does not exist
LINE 3: where person_nbr = store
                            ^
What's the correct syntax for the \prompt?

TIA,

Rich






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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected]
  Subject: Re: Using psql's \prompt command
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox